|
22 | 22 | from tarantool.response import Response
|
23 | 23 | from tarantool.request import (
|
24 | 24 | Request,
|
25 |
| - RequestOK, |
| 25 | + # RequestOK, |
26 | 26 | RequestCall,
|
27 | 27 | RequestDelete,
|
28 | 28 | RequestEval,
|
|
34 | 34 | RequestSubscribe,
|
35 | 35 | RequestUpdate,
|
36 | 36 | RequestUpsert,
|
37 |
| - RequestAuthenticate) |
38 |
| - |
| 37 | + RequestAuthenticate |
| 38 | +) |
39 | 39 | from tarantool.space import Space
|
40 | 40 | from tarantool.const import (
|
41 | 41 | SOCKET_TIMEOUT,
|
|
46 | 46 | IPROTO_GREETING_SIZE,
|
47 | 47 | ENCODING_DEFAULT,
|
48 | 48 | ITERATOR_EQ,
|
49 |
| - ITERATOR_ALL) |
50 |
| - |
| 49 | + ITERATOR_ALL |
| 50 | +) |
51 | 51 | from tarantool.error import (
|
52 | 52 | NetworkError,
|
53 |
| - DatabaseError, |
| 53 | + # DatabaseError, |
54 | 54 | NetworkWarning,
|
55 |
| - SchemaReloadException) |
56 |
| - |
57 |
| -from .schema import Schema |
58 |
| -from .utils import check_key, greeting_decode, version_id |
| 55 | + SchemaReloadException, |
| 56 | + warn |
| 57 | +) |
| 58 | +from tarantool.schema import Schema |
| 59 | +from tarantool.utils import check_key, greeting_decode, version_id |
59 | 60 |
|
60 | 61 |
|
61 | 62 | class Connection(object):
|
@@ -91,7 +92,9 @@ def __init__(self, host, port,
|
91 | 92 | if False than you have to call connect() manualy.
|
92 | 93 | '''
|
93 | 94 | if os.name == 'nt':
|
94 |
| - libc = ctypes.windll.LoadLibrary(ctypes.util.find_library('Ws2_32')) |
| 95 | + libc = ctypes.windll.LoadLibrary( |
| 96 | + ctypes.util.find_library('Ws2_32') |
| 97 | + ) |
95 | 98 | else:
|
96 | 99 | libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
|
97 | 100 | recv = self._sys_recv = libc.recv
|
@@ -177,15 +180,24 @@ def _recv(self, to_read):
|
177 | 180 | tmp = self._socket.recv(to_read)
|
178 | 181 | except OverflowError:
|
179 | 182 | self._socket.close()
|
180 |
| - raise NetworkError(socker.error(errno.ECONNRESET, |
181 |
| - "Too big packet. Closing connection to server")) |
| 183 | + err = socket.error( |
| 184 | + errno.ECONNRESET, |
| 185 | + "Too big packet. Closing connection to server" |
| 186 | + ) |
| 187 | + raise NetworkError(err) |
182 | 188 | except socket.error:
|
183 |
| - raise NetworkError(socket.error(errno.ECONNRESET, |
184 |
| - "Lost connection to server during query")) |
| 189 | + err = socket.error( |
| 190 | + errno.ECONNRESET, |
| 191 | + "Lost connection to server during query" |
| 192 | + ) |
| 193 | + raise NetworkError(err) |
185 | 194 | else:
|
186 | 195 | if len(tmp) == 0:
|
187 |
| - raise NetworkError(socket.error(errno.ECONNRESET, |
188 |
| - "Lost connection to server during query")) |
| 196 | + err = socket.error( |
| 197 | + errno.ECONNRESET, |
| 198 | + "Lost connection to server during query" |
| 199 | + ) |
| 200 | + raise NetworkError(err) |
189 | 201 | to_read -= len(tmp)
|
190 | 202 | buf += tmp
|
191 | 203 | return buf
|
@@ -261,7 +273,7 @@ def check(): # Check that connection is alive
|
261 | 273 | time.sleep(self.reconnect_delay)
|
262 | 274 | try:
|
263 | 275 | self.connect_basic()
|
264 |
| - except NetworkError as e: |
| 276 | + except NetworkError: |
265 | 277 | pass
|
266 | 278 | else:
|
267 | 279 | if self.connected:
|
@@ -394,7 +406,7 @@ def _join_v16(self, server_uuid):
|
394 | 406 | self._socket.sendall(bytes(request))
|
395 | 407 |
|
396 | 408 | while True:
|
397 |
| - resp = Response(self, self._read_response()); |
| 409 | + resp = Response(self, self._read_response()) |
398 | 410 | yield resp
|
399 | 411 | if resp.code == REQUEST_TYPE_OK or resp.code >= REQUEST_TYPE_ERROR:
|
400 | 412 | return
|
@@ -543,7 +555,8 @@ def upsert(self, space_name, tuple_value, op_list, **kwargs):
|
543 | 555 | space_name = self.schema.get_space(space_name).sid
|
544 | 556 | if isinstance(index_name, six.string_types):
|
545 | 557 | index_name = self.schema.get_index(space_name, index_name).iid
|
546 |
| - request = RequestUpsert(self, space_name, index_name, tuple_value, op_list) |
| 558 | + request = RequestUpsert(self, space_name, index_name, tuple_value, |
| 559 | + op_list) |
547 | 560 | return self._send_request(request)
|
548 | 561 |
|
549 | 562 | def update(self, space_name, key, op_list, **kwargs):
|
@@ -684,9 +697,10 @@ def select(self, space_name, key=None, **kwargs):
|
684 | 697 | index_name = kwargs.get("index", 0)
|
685 | 698 | iterator_type = kwargs.get("iterator")
|
686 | 699 |
|
687 |
| - if iterator_type == None: |
| 700 | + if iterator_type is None: |
688 | 701 | iterator_type = ITERATOR_EQ
|
689 |
| - if (key == None or (isinstance(key, (list, tuple)) and len(key) == 0)): |
| 702 | + if key is None or (isinstance(key, (list, tuple)) and |
| 703 | + len(key) == 0): |
690 | 704 | iterator_type = ITERATOR_ALL
|
691 | 705 |
|
692 | 706 | # Perform smart type checking (scalar / list of scalars / list of
|
@@ -717,7 +731,7 @@ def space(self, space_name):
|
717 | 731 | return Space(self, space_name)
|
718 | 732 |
|
719 | 733 | def generate_sync(self):
|
720 |
| - """\ |
| 734 | + ''' |
721 | 735 | Need override for async io connection
|
722 |
| - """ |
| 736 | + ''' |
723 | 737 | return 0
|
0 commit comments