Last active
November 22, 2019 19:09
-
-
Save schipiga/3518930155560074284bad7583fc028e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setblocking(): | |
setblocking_func = socket.socket.setblocking | |
def wrapper(self, flag): | |
if flag: | |
# prohibit timeout reset | |
timeout = socket.getdefaulttimeout() | |
if timeout: | |
self.settimeout(timeout) | |
else: | |
setblocking_func(self, flag) | |
else: | |
setblocking_func(self, flag) | |
wrapper.__doc__ = setblocking_func.__doc__ | |
wrapper.__name__ = setblocking_func.__name__ | |
return wrapper | |
socket.socket.setblocking = setblocking() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment