Skip to content

Commit 0f683b2

Browse files
committed
Fix connect error on windows (#70):
>>> import tarantool >>> tarantool.connect('48.12.22.123',3311) ``` Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> tarantool.connect('48.12.22.123',3311) File "C:\Python27\lib\site-packages\tarantool\__init__.py", line 47, in connect encoding=encoding) File "C:\Python27\lib\site-packages\tarantool\connection.py", line 93, in __init__ recv = self._sys_recv = libc.recv File "C:\Python27\lib\ctypes\__init__.py", line 378, in __getattr__ func = self.__getitem__(name) File "C:\Python27\lib\ctypes\__init__.py", line 383, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: function 'recv' not found ```
1 parent bd08927 commit 0f683b2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tarantool/connection.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import ctypes.util
1212
import socket
1313
import msgpack
14+
import os
1415

1516
try:
1617
from ctypes import c_ssize_t
@@ -89,7 +90,10 @@ def __init__(self, host, port,
8990
creates network connection.
9091
if False than you have to call connect() manualy.
9192
'''
92-
libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
93+
if os.name == 'nt':
94+
libc = ctypes.CDLL(ctypes.util.find_library('Ws2_32'), use_errno=True)
95+
else:
96+
libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
9397
recv = self._sys_recv = libc.recv
9498
recv.argtypes = [
9599
ctypes.c_int, ctypes.c_void_p, c_ssize_t, ctypes.c_int]

0 commit comments

Comments
 (0)