mirror of
https://github.com/python/cpython.git
synced 2025-11-07 09:02:02 +00:00
Added optional timeout to SocketHandler.makeSocket (SF #1695948)
This commit is contained in:
parent
55a1864832
commit
aa7b16a888
1 changed files with 3 additions and 1 deletions
|
|
@ -361,12 +361,14 @@ def __init__(self, host, port):
|
||||||
self.retryMax = 30.0
|
self.retryMax = 30.0
|
||||||
self.retryFactor = 2.0
|
self.retryFactor = 2.0
|
||||||
|
|
||||||
def makeSocket(self):
|
def makeSocket(self, timeout=1):
|
||||||
"""
|
"""
|
||||||
A factory method which allows subclasses to define the precise
|
A factory method which allows subclasses to define the precise
|
||||||
type of socket they want.
|
type of socket they want.
|
||||||
"""
|
"""
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
if hasattr(s, 'settimeout'):
|
||||||
|
s.settimeout(timeout)
|
||||||
s.connect((self.host, self.port))
|
s.connect((self.host, self.port))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue