]> granicus.if.org Git - python/commitdiff
logging's SocketHandler: get rid of some legacy code and use the newer socket.create_...
authorGiampaolo Rodola' <g.rodola@gmail.com>
Mon, 15 Oct 2012 14:57:37 +0000 (16:57 +0200)
committerGiampaolo Rodola' <g.rodola@gmail.com>
Mon, 15 Oct 2012 14:57:37 +0000 (16:57 +0200)
Lib/logging/handlers.py

index 2c5a634740a3f15c9caef2b0951d96dd2ab0e5ff..fbc59fac3ce1a59e19535031c85f95352e4621bd 100644 (file)
@@ -496,15 +496,7 @@ class SocketHandler(logging.Handler):
         A factory method which allows subclasses to define the precise
         type of socket they want.
         """
-        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        if hasattr(s, 'settimeout'):
-            s.settimeout(timeout)
-        try:
-            s.connect((self.host, self.port))
-            return s
-        except socket.error:
-            s.close()
-            raise
+        return socket.create_connection((self.host, self.port), timeout=timeout)
 
     def createSocket(self):
         """