From: Vinay Sajip Date: Mon, 9 Apr 2007 16:16:10 +0000 (+0000) Subject: Added optional timeout to SocketHandler.makeSocket (SF #1695948) X-Git-Tag: v2.6a1~1856 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa7b16a888eb53fdc4d7f194f3d49e6e8fe3ac24;p=python Added optional timeout to SocketHandler.makeSocket (SF #1695948) --- diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index f877c15aea..c713a11c26 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -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