Skip to content

Commit b630259

Browse files
authored
Merge pull request #354 type hints to preferred endpoint for get connection from pool
2 parents 8938db2 + d6e9176 commit b630259

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ydb/aio/pool.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import asyncio
22
import logging
33
import random
4+
import typing
45

56
from ydb import issues
67
from ydb.pool import ConnectionsCache as _ConnectionsCache, IConnectionPool
78

8-
from .connection import Connection
9+
from .connection import Connection, EndpointKey
910

1011
from . import resolver
1112

@@ -21,7 +22,7 @@ def __init__(self, use_all_nodes: bool = False):
2122

2223
self._fast_fail_error = None
2324

24-
async def get(self, preferred_endpoint=None, fast_fail=False, wait_timeout=10):
25+
async def get(self, preferred_endpoint: typing.Optional[EndpointKey] = None, fast_fail=False, wait_timeout=10):
2526

2627
if fast_fail:
2728
await asyncio.wait_for(self._fast_fail_event.wait(), timeout=wait_timeout)

ydb/pool.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
from concurrent import futures
66
import collections
77
import random
8+
import typing
89

910
from . import connection as connection_impl, issues, resolver, _utilities, tracing
1011
from abc import abstractmethod
1112

12-
from .connection import Connection
13+
from .connection import Connection, EndpointKey
1314

1415
logger = logging.getLogger(__name__)
1516

@@ -123,7 +124,7 @@ def subscribe(self):
123124
return subscription
124125

125126
@tracing.with_trace()
126-
def get(self, preferred_endpoint=None) -> Connection:
127+
def get(self, preferred_endpoint: typing.Optional[EndpointKey] = None) -> Connection:
127128
with self.lock:
128129
if preferred_endpoint is not None and preferred_endpoint.node_id in self.connections_by_node_id:
129130
return self.connections_by_node_id[preferred_endpoint.node_id]

0 commit comments

Comments
 (0)