1414
1515
1616class ConnectionState (enum .IntEnum ):
17- CONNECTING = 0
18- CONNECTED = 1
19- RECONNECTING = 2
20- DISCONNECTING = 3
21- DISCONNECTED = 4
17+ IDLE = 0
18+ CONNECTING = 1
19+ CONNECTED = 2
20+ RECONNECTING = 3
21+ DISCONNECTING = 4
22+ DISCONNECTED = 5
2223
2324
2425class Connection :
@@ -109,8 +110,8 @@ def __init__(self, *,
109110 self ._protocol = None
110111 self ._db = DbMock ()
111112
112- self ._state = ConnectionState .DISCONNECTED
113- self ._state_prev = ConnectionState .DISCONNECTED
113+ self ._state = ConnectionState .IDLE
114+ self ._state_prev = ConnectionState .IDLE
114115 self ._disconnect_waiter = None
115116 self ._reconnect_coro = None
116117
@@ -167,6 +168,7 @@ async def _connect(self, return_exceptions=True):
167168 ConnectionState .CONNECTING ,
168169 ConnectionState .CONNECTED ,
169170 ConnectionState .DISCONNECTING ,
171+ ConnectionState .DISCONNECTED ,
170172 }
171173 if self ._state in ignore_states :
172174 return
@@ -312,6 +314,7 @@ async def reconnect(self):
312314 Just calls disconnect() and connect()
313315 """
314316 await self .disconnect ()
317+ self ._set_state (ConnectionState .IDLE )
315318 await self .connect ()
316319
317320 @property
@@ -463,6 +466,7 @@ def ping(self, *, timeout=-1):
463466 """
464467 Ping request coroutine
465468 :param timeout: Request timeout
469+ :rtype: asynctnt.Response
466470 """
467471 return self ._db .ping (timeout = timeout )
468472
@@ -474,6 +478,7 @@ def call16(self, func_name, args=None, *, timeout=-1):
474478 :param func_name: function name to call
475479 :param args: arguments to pass to the function (list object)
476480 :param timeout: Request timeout
481+ :rtype: asynctnt.Response
477482 """
478483 return self ._db .call16 (func_name , args ,
479484 timeout = timeout )
@@ -488,6 +493,7 @@ def call(self, func_name, args=None, *, timeout=-1):
488493 :param func_name: function name to call
489494 :param args: arguments to pass to the function (list object)
490495 :param timeout: Request timeout
496+ :rtype: asynctnt.Response
491497 """
492498 return self ._db .call (func_name , args ,
493499 timeout = timeout )
@@ -500,6 +506,7 @@ def eval(self, expression, args=None, *, timeout=-1):
500506 :param args: arguments to pass to the function, that will
501507 execute your expression (list object)
502508 :param timeout: Request timeout
509+ :rtype: asynctnt.Response
503510 """
504511 return self ._db .eval (expression , args ,
505512 timeout = timeout )
@@ -519,6 +526,7 @@ def select(self, space, key=None, **kwargs):
519526 * asynctnt.Iterator object
520527 * string with an iterator name
521528 :param timeout: Request timeout
529+ :rtype: asynctnt.Response
522530 """
523531 return self ._db .select (space , key , ** kwargs )
524532
@@ -530,6 +538,7 @@ def insert(self, space, t, *, replace=False, timeout=-1):
530538 :param t: tuple to insert (list object)
531539 :param replace: performs replace request instead of insert
532540 :param timeout: Request timeout
541+ :rtype: asynctnt.Response
533542 """
534543 return self ._db .insert (space , t ,
535544 replace = replace , timeout = timeout )
@@ -541,6 +550,7 @@ def replace(self, space, t, *, timeout=-1):
541550 :param space: space id or space name.
542551 :param t: tuple to insert (list object)
543552 :param timeout: Request timeout
553+ :rtype: asynctnt.Response
544554 """
545555 return self ._db .replace (space , t ,
546556 timeout = timeout )
@@ -553,6 +563,7 @@ def delete(self, space, key, **kwargs):
553563 :param key: key to delete
554564 :param index: index id or name
555565 :param timeout: Request timeout
566+ :rtype: asynctnt.Response
556567 """
557568 return self ._db .delete (space , key , ** kwargs )
558569
@@ -581,6 +592,7 @@ def upsert(self, space, t, operations, **kwargs):
581592 Please refer to
582593 https://tarantool.org/doc/book/box/box_space.html?highlight=update#lua-function.space_object.update
583594 :param timeout: Request timeout
595+ :rtype: asynctnt.Response
584596 """
585597 return self ._db .upsert (space , t , operations , ** kwargs )
586598
0 commit comments