At http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/readv_close
------------------------------------------------------------
revno: 3795
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: John Arbash Meinel <[EMAIL PROTECTED]>
branch nick: readv_close
timestamp: Fri 2008-10-24 19:30:07 -0500
message:
During Transport.readv() close the file handle if we can.
This helps reduce open file handles, especially on Windows where it prevents
us from doing other things with the file.
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2008-10-06 06:34:36 +0000
+++ b/bzrlib/transport/__init__.py 2008-10-25 00:30:07 +0000
@@ -661,6 +661,7 @@
"""
# We are going to iterate multiple times, we need a list
offsets = list(offsets)
+ remaining = len(offsets)
sorted_offsets = sorted(offsets)
# turn the list of offsets into a stack
@@ -688,6 +689,12 @@
# Now that we've read some data, see if we can yield anything back
while cur_offset_and_size in data_map:
this_data = data_map.pop(cur_offset_and_size)
+ remaining -= 1
+ if remaining <= 0:
+ # Close the file handle as we are done yielding data.
+ close = getattr(fp, 'close', None)
+ if close is not None:
+ close()
yield cur_offset_and_size[0], this_data
cur_offset_and_size = offset_stack.next()
--
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits