Handle windows WSAEWOULDBLOCK
This commit is contained in:
parent
dcc9f62651
commit
b7053f2110
@ -29,10 +29,6 @@ import signal
|
|||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
import win32api
|
|
||||||
import win32con
|
|
||||||
|
|
||||||
from fah import *
|
from fah import *
|
||||||
from fah.util import status_to_color, make_row, get_home_dir
|
from fah.util import status_to_color, make_row, get_home_dir
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ if sys.platform == 'win32':
|
|||||||
WSAGetLastError = windll.ws2_32.WSAGetLastError
|
WSAGetLastError = windll.ws2_32.WSAGetLastError
|
||||||
|
|
||||||
debug = False
|
debug = False
|
||||||
|
WSAEWOULDBLOCK = 10035
|
||||||
|
|
||||||
class Connection:
|
class Connection:
|
||||||
def __init__(self, address = 'localhost', port = 36330, password = None,
|
def __init__(self, address = 'localhost', port = 36330, password = None,
|
||||||
@ -101,7 +101,8 @@ class Connection:
|
|||||||
self.socket.setblocking(0)
|
self.socket.setblocking(0)
|
||||||
err = self.socket.connect_ex((self.address, self.port))
|
err = self.socket.connect_ex((self.address, self.port))
|
||||||
|
|
||||||
if err != 0 and not err in [errno.EINPROGRESS, errno.EWOULDBLOCK]:
|
if err != 0 and not err in [
|
||||||
|
errno.EINPROGRESS, errno.EWOULDBLOCK, WSAEWOULDBLOCK]:
|
||||||
self.fail_reason = 'connect'
|
self.fail_reason = 'connect'
|
||||||
raise Exception, 'Connection failed: ' + errno.errorcode[err]
|
raise Exception, 'Connection failed: ' + errno.errorcode[err]
|
||||||
|
|
||||||
@ -153,7 +154,7 @@ class Connection:
|
|||||||
|
|
||||||
except socket.error, (err, msg):
|
except socket.error, (err, msg):
|
||||||
# Error codes for nothing to read
|
# Error codes for nothing to read
|
||||||
if err not in [errno.EAGAIN, errno.EWOULDBLOCK]:
|
if err not in [errno.EAGAIN, errno.EWOULDBLOCK, WSAEWOULDBLOCK]:
|
||||||
if bytesRead: return bytesRead
|
if bytesRead: return bytesRead
|
||||||
self.connection_error(err, msg)
|
self.connection_error(err, msg)
|
||||||
raise
|
raise
|
||||||
@ -178,7 +179,7 @@ class Connection:
|
|||||||
|
|
||||||
except socket.error, (err, msg):
|
except socket.error, (err, msg):
|
||||||
# Error codes for write buffer full
|
# Error codes for write buffer full
|
||||||
if err not in [errno.EAGAIN, errno.EWOULDBLOCK]:
|
if err not in [errno.EAGAIN, errno.EWOULDBLOCK, WSAEWOULDBLOCK]:
|
||||||
if bytesWritten: return bytesWritten
|
if bytesWritten: return bytesWritten
|
||||||
self.connection_error(err, msg)
|
self.connection_error(err, msg)
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user