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