Skip to content

Commit 2ef0026

Browse files
committed
style fix
1 parent 2931699 commit 2ef0026

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

ydb/_topic_common/common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def unsafe_call_with_result(self, coro: typing.Coroutine, timeout: TimeoutType):
8686
except concurrent.futures.TimeoutError:
8787
raise TimeoutError()
8888
finally:
89-
f.cancel()
89+
if not f.done():
90+
f.cancel()
9091

9192
def safe_call_with_result(self, coro: typing.Coroutine, timeout: TimeoutType):
9293
"""
@@ -126,11 +127,8 @@ async def call_coro():
126127
except asyncio.CancelledError:
127128
res.set_exception(TimeoutError())
128129

129-
async def sleep0():
130-
await asyncio.sleep(0)
131-
132130
coro_future = asyncio.run_coroutine_threadsafe(call_coro(), self._loop)
133-
asyncio.run_coroutine_threadsafe(sleep0(), self._loop).result()
131+
asyncio.run_coroutine_threadsafe(asyncio.sleep(0), self._loop).result()
134132
coro_future.cancel()
135133
return res.result()
136134

ydb/_topic_common/common_test.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,8 @@ async def callback():
217217
caller.safe_call_with_result(callback(), timeout)
218218
finished = time.monotonic()
219219

220-
async def sleep0():
221-
await asyncio.sleep(0)
222-
223220
# wait one loop for handle task cancelation
224-
asyncio.run_coroutine_threadsafe(sleep0(), separate_loop)
221+
asyncio.run_coroutine_threadsafe(asyncio.sleep(0), separate_loop)
225222

226223
assert callback_loop is separate_loop
227224
assert finished - start > timeout

ydb/_topic_writer/topic_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def __init__(self, message: str):
178178

179179
class TopicWriterClosedError(ydb.Error):
180180
def __init__(self):
181-
super(TopicWriterClosedError, self).__init__("Topic writer already closed")
181+
super().__init__("Topic writer already closed")
182182

183183

184184
class TopicWriterRepeatableError(TopicWriterError):

0 commit comments

Comments
 (0)