]> granicus.if.org Git - python/commitdiff
Fix a problem reported by Oleg Broytmann, who complains that very
authorGuido van Rossum <guido@python.org>
Wed, 24 May 2000 13:21:46 +0000 (13:21 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 24 May 2000 13:21:46 +0000 (13:21 +0000)
often, ftp URLs hang in the final close.  Further analysis suggests
that this is because the close hook in addclosehook() calls the hook
before acually closing the connection.  The hook, in this case, waits
for the '226 Transfer complete' status from the server on the command
socket.  However, more and more ftp servers only send this status when
the data socket has actually been closed -- causing a deadlock.

The fix is simple: in addclosehook.close(), call addbase.close()
*before* calling the closehook.

Lib/urllib.py

index 7328f9a69134a19d09d1030ff9da5fb8f0acd335..c96dd64b978d61794db9f0d858494f0c1da6109a 100644 (file)
@@ -726,11 +726,11 @@ class addclosehook(addbase):
         self.hookargs = hookargs
 
     def close(self):
+        addbase.close(self)
         if self.closehook:
             apply(self.closehook, self.hookargs)
             self.closehook = None
             self.hookargs = None
-        addbase.close(self)
 
 class addinfo(addbase):
     """class to add an info() method to an open file."""