Skip to content

Commit 2931699

Browse files
committed
timeout style
1 parent 6e749ed commit 2931699

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

ydb/_topic_common/common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ def unsafe_call_with_future(
7676
"""
7777
return asyncio.run_coroutine_threadsafe(coro, self._loop)
7878

79-
def unsafe_call_with_result(
80-
self, coro: typing.Coroutine, timeout: typing.Union[int, float, None]
81-
):
79+
def unsafe_call_with_result(self, coro: typing.Coroutine, timeout: TimeoutType):
8280
"""
8381
returned result from coro may be lost by race future cancel by timeout and return value from coroutine
8482
"""

ydb/_topic_reader/topic_reader_sync.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from typing import List, Union, Iterable, Optional
55

66
from ydb._grpc.grpcwrapper.common_utils import SupportedDriverType
7-
from ydb._topic_common.common import _get_shared_event_loop, CallFromSyncToAsync
7+
from ydb._topic_common.common import (
8+
_get_shared_event_loop,
9+
CallFromSyncToAsync,
10+
TimeoutType,
11+
)
812
from ydb._topic_reader import datatypes
913
from ydb._topic_reader.datatypes import PublicMessage, PublicBatch, ICommittable
1014
from ydb._topic_reader.topic_reader import (
@@ -156,7 +160,7 @@ def commit(
156160
self._caller.call_sync(self._async_reader.commit(mess))
157161

158162
def commit_with_ack(
159-
self, mess: ICommittable, timeout: typing.Union[int, float, None] = None
163+
self, mess: ICommittable, timeout: TimeoutType = None
160164
) -> Union[CommitResult, List[CommitResult]]:
161165
"""
162166
write commit message to a buffer and wait ack from the server.
@@ -193,7 +197,7 @@ def flush(self):
193197
"""
194198
raise NotImplementedError()
195199

196-
def close(self, *, timeout: typing.Union[int, float, None] = None):
200+
def close(self, *, timeout: TimeoutType = None):
197201
if self._closed:
198202
return
199203

ydb/_topic_writer/topic_writer_sync.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import asyncio
4-
import typing
54
from concurrent.futures import Future
65
from typing import Union, List, Optional
76

@@ -57,9 +56,7 @@ def __enter__(self):
5756
def __exit__(self, exc_type, exc_val, exc_tb):
5857
self.close()
5958

60-
def close(
61-
self, *, flush: bool = True, timeout: typing.Union[int, float, None] = None
62-
):
59+
def close(self, *, flush: bool = True, timeout: TimeoutType = None):
6360
if self._closed:
6461
return
6562

0 commit comments

Comments
 (0)