Skip to content

Commit d28acc7

Browse files
committed
use correct socket library on windows platform
1 parent 0f683b2 commit d28acc7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tarantool/connection.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, host, port,
9191
if False than you have to call connect() manualy.
9292
'''
9393
if os.name == 'nt':
94-
libc = ctypes.CDLL(ctypes.util.find_library('Ws2_32'), use_errno=True)
94+
libc = ctypes.windll.LoadLibrary(ctypes.util.find_library('Ws2_32'))
9595
else:
9696
libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
9797
recv = self._sys_recv = libc.recv
@@ -233,8 +233,13 @@ def check(): # Check that connection is alive
233233
if e.errno == errno.EBADF:
234234
return errno.ECONNRESET
235235
else:
236-
self._sys_recv(sock_fd, buf, 1,
237-
socket.MSG_DONTWAIT | socket.MSG_PEEK)
236+
if os.name == 'nt':
237+
flag = socket.MSG_PEEK
238+
self._socket.setblocking(False)
239+
else:
240+
flag = socket.MSG_DONTWAIT | socket.MSG_PEEK
241+
self._sys_recv(sock_fd, buf, 1, flag)
242+
238243
if ctypes.get_errno() == errno.EAGAIN:
239244
ctypes.set_errno(0)
240245
return errno.EAGAIN

0 commit comments

Comments
 (0)