def settimeout():
"""Function to return wrapper over ``socket.socket.set_timeout``."""
def wrapper(self, timeout):
"""Wrapper to prevent ability change default socket timeout to None.
Note:
This is workaround for https://github.com/kennethreitz/requests/blob/5524472cc76ea00d64181505f1fbb7f93f11cc2b/requests/packages/urllib3/connectionpool.py#L381 # noqa
Args:
timeout (int): Seconds of socket timeout.
"""
if self.gettimeout() and timeout is None:
return
settimeout_func(self, timeout)
settimeout_func = six.get_unbound_function(socket.socket.settimeout)
wrapper.__doc__ = settimeout_func.__doc__
wrapper.__name__ = settimeout_func.__name__
return wrapper
评论列表
文章目录