At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3800
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Canonical.com Patch Queue Manager <[EMAIL PROTECTED]>
branch nick: +trunk
timestamp: Mon 2008-10-27 19:13:00 +0000
message:
  (jam) Transport._seek_and_readv() closes the fp before yielding the
        last bit of data.
modified:
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
    ------------------------------------------------------------
    revno: 3794.2.2
    revision-id: [EMAIL PROTECTED]
    parent: [EMAIL PROTECTED]
    committer: John Arbash Meinel <[EMAIL PROTECTED]>
    branch nick: readv_close
    timestamp: Mon 2008-10-27 10:30:29 -0500
    message:
      Instead of counting the remaining offsets, trap the offset exception
      This should give the same result, but it means one less thing to keep 
track of.
      Also, make fp.close() a required attribute, rather than optional.
    modified:
      bzrlib/transport/__init__.py   
transport.py-20050711165921-4978aa7ce1285ad5
    ------------------------------------------------------------
    revno: 3794.2.1
    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:
      bzrlib/transport/__init__.py   
transport.py-20050711165921-4978aa7ce1285ad5
=== 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-27 15:30:29 +0000
@@ -688,8 +688,21 @@
             # 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)
-                yield cur_offset_and_size[0], this_data
-                cur_offset_and_size = offset_stack.next()
+                this_offset = cur_offset_and_size[0]
+                try:
+                    cur_offset_and_size = offset_stack.next()
+                except StopIteration:
+                    # Close the file handle as there will be no more data
+                    # The handle would normally be cleaned up as this code goes
+                    # out of scope, but as we are a generator, not all code
+                    # will re-enter once we have consumed all the expected
+                    # data. For example:
+                    #   zip(range(len(requests)), readv(foo, requests))
+                    # Will stop because the range is done, and not run the
+                    # cleanup code for the readv().
+                    fp.close()
+                    cur_offset_and_size = None
+                yield this_offset, this_data
 
     def _sort_expand_and_combine(self, offsets, upper_limit):
         """Helper for readv.


-- 
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits

Reply via email to