Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Lib/asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@
import os
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
errorcode
errorcode, \
WSAEWOULDBLOCK, WSAENOTCONN, WSAEINPROGRESS, WSAEALREADY, WSAEISCONN, \
WSAECONNABORTED, WSAENOTCONN, WSAEBADF

_DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
EBADF))
EBADF, WSAENOTCONN, WSAECONNABORTED, WSAEBADF))

try:
socket_map
Expand Down Expand Up @@ -249,7 +251,7 @@ def __init__(self, sock=None, map=None):
try:
self.addr = sock.getpeername()
except socket.error, err:
if err.args[0] in (ENOTCONN, EINVAL):
if err.args[0] in (ENOTCONN, EINVAL, WSAENOTCONN):
# To handle the case where we got an unconnected
# socket.
self.connected = False
Expand Down Expand Up @@ -345,7 +347,7 @@ def connect(self, address):
self.connected = False
self.connecting = True
err = self.socket.connect_ex(address)
if err in (EINPROGRESS, EALREADY, EWOULDBLOCK) \
if err in (EINPROGRESS, EALREADY, EWOULDBLOCK, WSAEINPROGRESS, WSAEALREADY, WSAEWOULDBLOCK) \
or err == EINVAL and os.name in ('nt', 'ce'):
self.addr = address
return
Expand All @@ -362,7 +364,7 @@ def accept(self):
except TypeError:
return None
except socket.error as why:
if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN, WSAEWOULDBLOCK, WSAECONNABORTED):
return None
else:
raise
Expand All @@ -374,7 +376,7 @@ def send(self, data):
result = self.socket.send(data)
return result
except socket.error, why:
if why.args[0] == EWOULDBLOCK:
if why.args[0] in(EWOULDBLOCK, WSAEWOULDBLOCK):
return 0
elif why.args[0] in _DISCONNECTED:
self.handle_close()
Expand Down Expand Up @@ -408,7 +410,7 @@ def close(self):
try:
self.socket.close()
except socket.error, why:
if why.args[0] not in (ENOTCONN, EBADF):
if why.args[0] not in (ENOTCONN, EBADF, WSAENOTCONN, WSAEBADF):
raise

# cheap inheritance, used to pass all other attribute
Expand Down