ydb-python-sdk
ydb-python-sdk copied to clipboard
bug: unexpected asyncio.CancelledError on writer.close
Bug Report
YDB Python SDK version: 3.3.5
Current behavior: Calling .close() method of async topic writer may lead to unexpected asyncio.CancelledError
File ".../ydb/_topic_writer/topic_writer_asyncio.py", line 87, in close
await self._reconnector.close(flush)
File ".../ydb/_topic_writer/topic_writer_asyncio.py", line 257, in close
self._check_stop()
File ".../ydb/_topic_writer/topic_writer_asyncio.py", line 338, in _check_stop
raise self._stop_reason.exception()
File ".../ydb/_topic_writer/topic_writer_asyncio.py", line 374, in _connection_loop
done.pop().result() # need for raise exception - reason of stop task
^^^^^^^^^^^^^^^^^^^
File ".../ydb/_topic_writer/topic_writer_asyncio.py", line 504, in _read_loop
resp = await writer.receive()
^^^^^^^^^^^^^^^^^^^^^^
File ".../ydb/_topic_writer/topic_writer_asyncio.py", line 626, in receive
item = await self._stream.receive()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ydb/_grpc/grpcwrapper/common_utils.py", line 205, in receive
grpc_message = await self.from_server_grpc.__anext__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../grpcio/grpc/aio/_call.py", line 326, in _fetch_stream_responses
await self._raise_for_status()
File ".../grpcio/grpc/aio/_call.py", line 233, in _raise_for_status
raise asyncio.CancelledError()
asyncio.exceptions.CancelledError
Expected behavior: raise error that a subclass of ydb.Error(...)
Steps to reproduce: reproduces in cases, when trying to close a writer that was not used for a while