[Python-checkins] cpython: Changed where socket close is called on connection failure.

vinay.sajip python-checkins at python.org
Sat May 7 16:55:55 CEST 2011


http://hg.python.org/cpython/rev/038bb7ac7c4e
changeset: 69905:038bb7ac7c4e
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Sat May 07 15:55:47 2011 +0100
summary:
 Changed where socket close is called on connection failure.
files:
 Lib/logging/handlers.py | 11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -446,8 +446,12 @@
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 if hasattr(s, 'settimeout'):
 s.settimeout(timeout)
- s.connect((self.host, self.port))
- return s
+ try:
+ s.connect((self.host, self.port))
+ return s
+ except socket.error:
+ s.close()
+ raise
 
 def createSocket(self):
 """
@@ -469,9 +473,6 @@
 self.retryTime = None # next time, no delay before trying
 except socket.error:
 #Creation failed, so set the retry time and return.
- if self.sock is not None:
- self.sock.close()
- self.sock = None
 if self.retryTime is None:
 self.retryPeriod = self.retryStart
 else:
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /