Message80393
As for ftplib patch you should make sure that close() gets called in any
case but never more than once.
You can use "finally" to satisfy the first requirement and "self.sock is
not None" to check the second condition:
+ def __exit__(self, *args):
+ """Context management protocol.
+
+ Will try to quit() if active, then close().
+ If not active, a simple close() call is made.
+ """
+ if self.sock is not None and self.getwelcome() is not None:
+ try:
+ self.quit()
+ except socket.error, e:
+ # [Errno 61] is Connection refused
+ # if the error is different, we want to raise it.
+ if e.errno != 61:
+ raise
+ finally:
+ if self.sock is not None:
+ self.close()
+ else:
+ self.close() |
|
Date |
User |
Action |
Args |
2009-01-23 01:44:24 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola, belopolsky, pitrou, tarek |
2009-01-23 01:44:23 | giampaolo.rodola | set | messageid: <1232675063.76.0.114823678626.issue4972@psf.upfronthosting.co.za> |
2009-01-23 01:44:22 | giampaolo.rodola | link | issue4972 messages |
2009-01-23 01:44:20 | giampaolo.rodola | create | |
|