tarantool / tarantool-python

Python client library for Tarantool
https://www.tarantool.io
BSD 2-Clause "Simplified" License
101 stars 46 forks source link

Reconnect on each request #47

Closed akopytov closed 8 years ago

akopytov commented 9 years ago

I noticed that my test program reconnects on each request. Debugging and code analysis reveals this code in connection.py as the culprit:

205             def check():  # Check that connection is alive
206                 buf = ctypes.create_string_buffer(2)
207                 self._sys_recv(self._socket.fileno(), buf, 1,
208                         socket.MSG_DONTWAIT | socket.MSG_PEEK)
209  ->             if ctypes.get_errno() == errno.EAGAIN:
210                     ctypes.set_errno(0)
211                     return errno.EAGAIN
212                 return (ctypes.get_errno() if ctypes.get_errno()
213                         else errno.ECONNRESET)

self._sys_recv() always returns EFAULT (Bad address) for me, so connection is always considered dead. I'm not a Python expert, but could it be a bug in the way _sys_recv() is defined/used?

bigbes commented 9 years ago

What's your os? On Jan 5, 2015 9:59 PM, "akopytov" notifications@github.com wrote:

I noticed that my test program reconnects on each request. Debugging and code analysis reveals this code in connection.py as the culprit:

205 def check(): # Check that connection is alive 206 buf = ctypes.create_string_buffer(2) 207 self._sys_recv(self._socket.fileno(), buf, 1, 208 socket.MSG_DONTWAIT | socket.MSG_PEEK) 209 -> if ctypes.get_errno() == errno.EAGAIN: 210 ctypes.set_errno(0) 211 return errno.EAGAIN 212 return (ctypes.get_errno() if ctypes.get_errno() 213 else errno.ECONNRESET)

self._sys_recv() always returns EFAULT (Bad address) for me, so connection is always considered dead. I'm not a Python expert, but could it be a bug in the way _sys_recv() is defined/used?

— Reply to this email directly or view it on GitHub https://github.com/tarantool/tarantool-python/issues/47.

akopytov commented 9 years ago

Sorry, I forgot to mention. It's OSX.

bigbes commented 8 years ago

Fixed by @mejedi