]> granicus.if.org Git - python/commitdiff
Added optional timeout to SocketHandler.makeSocket (SF #1695948)
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 9 Apr 2007 16:16:10 +0000 (16:16 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Mon, 9 Apr 2007 16:16:10 +0000 (16:16 +0000)
Lib/logging/handlers.py

index f877c15aea65e0fc80dde37f5325eaf1209d0c3e..c713a11c26c1207745b46681771047b635bab544 100644 (file)
@@ -361,12 +361,14 @@ class SocketHandler(logging.Handler):
         self.retryMax = 30.0
         self.retryFactor = 2.0
 
-    def makeSocket(self):
+    def makeSocket(self, timeout=1):
         """
         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)
         s.connect((self.host, self.port))
         return s