Skip to content

Commit b20057c

Browse files
Fix by comments in PR. Make refresh before request
Remove useless reconnect kwarg. Some test clean up Fix test on win platform. Flake8 cleanup Fix compat with init mesh builder Fix compat Mesh class with original Connection Fixed variables names. Reworked strategy class. Reorked and added tests. Some small cleanup.
1 parent b087be0 commit b20057c

File tree

10 files changed

+331
-248
lines changed

10 files changed

+331
-248
lines changed

.travis.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,15 @@ env:
1010
- TARGET=test
1111
- OS=el DIST=6
1212
- OS=el DIST=7
13-
- OS=fedora DIST=24
14-
- OS=fedora DIST=25
15-
- OS=ubuntu DIST=precise
13+
- OS=fedora DIST=28
14+
- OS=fedora DIST=29
1615
- OS=ubuntu DIST=trusty
1716
- OS=ubuntu DIST=xenial
18-
# - OS=debian DIST=wheezy
17+
- OS=ubuntu DIST=bionic
18+
- OS=ubuntu DIST=disco
1919
- OS=debian DIST=jessie
2020
- OS=debian DIST=stretch
21-
22-
matrix:
23-
allow_failures:
24-
# - env: OS=el DIST=6
25-
# - env: OS=el DIST=7
26-
# - env: OS=fedora DIST=24
27-
# - env: OS=fedora DIST=25
28-
# - env: OS=ubuntu DIST=precise
29-
# - env: OS=ubuntu DIST=trusty
30-
# - env: OS=ubuntu DIST=xenial
31-
# - env: OS=ubuntu DIST=yakkety
32-
# - env: OS=debian DIST=wheezy
33-
# - env: OS=debian DIST=jessie
34-
# - env: OS=debian DIST=stretch
21+
- OS=debian DIST=buster
3522

3623
script:
3724
- git describe --long
@@ -100,6 +87,16 @@ deploy:
10087
on:
10188
branch: master
10289
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}"
90+
- provider: packagecloud
91+
username: tarantool
92+
repository: "2_2"
93+
token: ${PACKAGECLOUD_TOKEN}
94+
dist: ${OS}/${DIST}
95+
package_glob: build/*.{rpm,deb}
96+
skip_cleanup: true
97+
on:
98+
branch: master
99+
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}"
103100

104101
notifications:
105102
email:

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ How to use the connector
8888
con = tarantool.Connection(host='localhost',
8989
port=3301,
9090
user='test',
91-
password='test',
92-
connect_now=True)
91+
password='test')
9392
9493
95-
resp = con.eval('return "Hello Wrold!"')
94+
resp = con.eval('return "Hello World!"')
9695
if resp.data[0] == "Hello World!":
9796
print('Ok')
9897

tarantool/connection.py

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ def __init__(self, host, port,
126126
self.encoding = encoding
127127
self.call_16 = call_16
128128
self.connection_timeout = connection_timeout
129-
self.authenticated = False
130129
if connect_now:
131130
self.connect()
132131

133132
def close(self):
134133
'''
135134
Close connection to the server
136135
'''
136+
self.connected = False
137137
self._socket.close()
138138
self._socket = None
139139

140140
def connect_basic(self):
141-
if self.host == None:
141+
if self.host is None:
142142
self.connect_unix()
143143
else:
144144
self.connect_tcp()
@@ -201,11 +201,9 @@ def connect(self):
201201
:raise: `NetworkError`
202202
'''
203203
try:
204-
self.authenticated = False
205204
self.connect_basic()
206205
self.handshake()
207206
self.load_schema()
208-
self.authenticated = True
209207
except Exception as e:
210208
self.connected = False
211209
raise NetworkError(e)
@@ -295,13 +293,12 @@ def check(): # Check that connection is alive
295293
retbytes = self._sys_recv(sock_fd, buf, 1, flag)
296294

297295
err = 0
298-
if os.name!= 'nt':
296+
if os.name != 'nt':
299297
err = ctypes.get_errno()
300298
else:
301299
err = ctypes.get_last_error()
302300
self._socket.setblocking(True)
303301

304-
305302
WWSAEWOULDBLOCK = 10035
306303
if (retbytes < 0) and (err == errno.EAGAIN or
307304
err == errno.EWOULDBLOCK or
@@ -368,38 +365,20 @@ def call(self, func_name, *args):
368365
369366
:param func_name: stored Lua function name
370367
:type func_name: str
371-
:param args: list of function arguments
372-
:type args: list or tuple
368+
:param args: function arguments
369+
:type args: tuple
373370
374371
:rtype: `Response` instance
375372
'''
376373

374+
assert isinstance(func_name, str)
375+
377376
# This allows to use a tuple or list as an argument
378377
if len(args) == 1 and isinstance(args[0], (list, tuple)):
379378
args = args[0]
380379

381-
return self.call_ex(func_name, args, True)
382-
383-
def call_ex(self, func_name, args=[], reconnect=True):
384-
'''
385-
Execute CALL request. Call stored Lua function.
386-
387-
:param func_name: stored Lua function name
388-
:type func_name: str
389-
:param args: list of function arguments
390-
:type args: list or tuple
391-
:param reconnect: reconnect before call
392-
:type reconnect: boolean
393-
394-
:rtype: `Response` instance
395-
'''
396-
assert isinstance(func_name, str)
397-
398380
request = RequestCall(self, func_name, args, self.call_16)
399-
if reconnect:
400-
response = self._send_request(request)
401-
else:
402-
response = self._send_request_wo_reconnect(request)
381+
response = self._send_request(request)
403382
return response
404383

405384
def eval(self, expr, *args):
@@ -413,34 +392,14 @@ def eval(self, expr, *args):
413392
414393
:rtype: `Response` instance
415394
'''
395+
assert isinstance(expr, str)
416396

417397
# This allows to use a tuple or list as an argument
418398
if len(args) == 1 and isinstance(args[0], (list, tuple)):
419399
args = args[0]
420400

421-
return self.eval_ex(expr, args, True)
422-
423-
def eval_ex(self, expr, args=[], reconnect=True):
424-
'''
425-
Execute EVAL request. Eval Lua expression.
426-
427-
:param expr: Lua expression
428-
:type expr: str
429-
:param args: list of function arguments
430-
:type args: list or tuple
431-
:param reconnect: reconnect before call
432-
:type reconnect: boolean
433-
434-
:rtype: `Response` instance
435-
'''
436-
assert isinstance(expr, str)
437-
438401
request = RequestEval(self, expr, args)
439-
if reconnect:
440-
response = self._send_request(request)
441-
else:
442-
response = self._send_request_wo_reconnect(request)
443-
return response
402+
return self._send_request(request)
444403

445404
def replace(self, space_name, values):
446405
'''

tarantool/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@
8787
# Default delay between attempts to reconnect (seconds)
8888
RECONNECT_DELAY = 0.1
8989
# Default cluster nodes list refresh interval (seconds)
90-
NODES_REFRESH_INTERVAL = 300
90+
CLUSTER_DISCOVERY_DELAY = 60

0 commit comments

Comments
 (0)