Commit 283b6fea authored by Jason Madden's avatar Jason Madden

attempt to fix the dontwait tests on linux. don't define sndmsg/recvmsg on windows

parent e05b717f
...@@ -322,14 +322,17 @@ class socket(object): ...@@ -322,14 +322,17 @@ class socket(object):
raise raise
self._wait(self._read_event) self._wait(self._read_event)
def recvmsg(self, *args): if hasattr(_socket.socket, 'sendmsg'):
while True: # Only on Unix
try:
return _socket.socket.recvmsg(self._sock, *args) def recvmsg(self, *args):
except error as ex: while True:
if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0: try:
raise return _socket.socket.recvmsg(self._sock, *args)
self._wait(self._read_event) except error as ex:
if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
raise
self._wait(self._read_event)
def recvfrom(self, *args): def recvfrom(self, *args):
while True: while True:
...@@ -413,19 +416,26 @@ class socket(object): ...@@ -413,19 +416,26 @@ class socket(object):
return 0 return 0
raise raise
def sendmsg(self, *args): if hasattr(_socket.socket, 'sendmsg'):
try: # Only on Unix
return _socket.socket.sendmsg(self._sock, *args) def sendmsg(self, buffers, ancdata=(), flags=0, address=None):
except error as ex:
if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
raise
self._wait(self._write_event)
try: try:
return _socket.socket.sendmsg(self._sock, *args) return _socket.socket.sendmsg(self._sock, buffers, ancdata, flags, address)
except error as ex2: except error as ex:
if ex2.args[0] == EWOULDBLOCK: if flags & getattr(_socket, 'MSG_DONTWAIT', 0):
return 0 # Enable non-blocking behaviour
raise # XXX: Do all platforms that have sendmsg have MSG_DONTWAIT?
raise
if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
raise
self._wait(self._write_event)
try:
return _socket.socket.sendmsg(self._sock, buffers, ancdata, flags, address)
except error as ex2:
if ex2.args[0] == EWOULDBLOCK:
return 0
raise
def setblocking(self, flag): def setblocking(self, flag):
if flag: if flag:
......
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