Kaydet (Commit) 985b68e6 authored tarafından Giampaolo Rodolà's avatar Giampaolo Rodolà

Store all errors signaling a disconnection into a global frozenset to save some…

Store all errors signaling a disconnection into a global frozenset to save some computation time on recv() and send().
üst 7d49bc99
......@@ -56,6 +56,8 @@ import os
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, errorcode
DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED))
try:
socket_map
except NameError:
......@@ -364,7 +366,7 @@ class dispatcher:
except socket.error as why:
if why.args[0] == EWOULDBLOCK:
return 0
elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
elif why.args[0] in DISCONNECTED:
self.handle_close()
return 0
else:
......@@ -382,7 +384,7 @@ class dispatcher:
return data
except socket.error as why:
# winsock sometimes throws ENOTCONN
if why.args[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
if why.args[0] in DISCONNECTED:
self.handle_close()
return b''
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment