summaryrefslogtreecommitdiffstats
path: root/Lib/logging/handlers.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2011-05-07 14:55:47 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2011-05-07 14:55:47 (GMT)
commitb37cd392028ec395dccc63e57cd43133cb274f8d (patch)
tree51a0554ac4b7a939f361b94c0fbc7445a1ac327e /Lib/logging/handlers.py
parenta55efb3b6fe8c386a01b7fe7e9cf91d455fb4b7a (diff)
downloadcpython-b37cd392028ec395dccc63e57cd43133cb274f8d.zip
cpython-b37cd392028ec395dccc63e57cd43133cb274f8d.tar.gz
cpython-b37cd392028ec395dccc63e57cd43133cb274f8d.tar.bz2
Changed where socket close is called on connection failure.
Diffstat (limited to 'Lib/logging/handlers.py')
-rw-r--r--Lib/logging/handlers.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 7296472..a0b53e8 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -446,8 +446,12 @@ class SocketHandler(logging.Handler):
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 @@ class SocketHandler(logging.Handler):
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: