tarantool / tarantool-python

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

Add connection_timeout parameter #115

Closed bofm closed 5 years ago

bofm commented 5 years ago

When a remote server does not respond, the connection times out longer than Connection. socket_timeout.

nmap -Pn 10.0.0.1 -p 3301

Starting Nmap 7.50 ( https://nmap.org ) at 2019-03-04 18:02 MSK
Nmap scan report for 10.0.0.1
Host is up.

PORT     STATE    SERVICE
3301/tcp filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 3.92 seconds
time python -c '
import tarantool
try:
    tarantool.Connection("10.0.0.1", 3301, socket_timeout=1, reconnect_max_attempts=0)
except Exception as e:
    print(e.__class__.__name__, e)
'

NetworkError (60, 'Operation timed out')
python -c   0.08s user 0.03s system 0% cpu 1:20.06 total

The problem is here https://github.com/tarantool/tarantool-python/blob/18bf4084d7fbf48ee6bdef8d43bb145ae1106bf9/tarantool/connection.py#L199

Expected behavior:

NetworkError should be raised after Connection.socket_timeout has passed.

Totktonada commented 5 years ago

It is not really a bug, but the feature request to add the connection_timeout parameter.