Though asyncio.create_task is run after timeout,
self._keepalive_socket() is run right after connect.
When the socket is unexpectedly canceled, this happens
never-awaited coroutine error.
/opt/homebrew-x86/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py:73: RuntimeWarning: coroutine 'KeepAliveWebsocket._keepalive_socket' was never awaited
Coroutine created at (most recent call last)
File "/opt/homebrew-x86/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/opt/homebrew-x86/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete
self.run_forever()
File "/opt/homebrew-x86/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
self._run_once()
File "/opt/homebrew-x86/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1882, in _run_once
handle._run()
File "/opt/homebrew-x86/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File
async with self.socket_manager.futures_user_socket() as stream:
File "/Users/user/Projects/python-binance/binance/streams.py", line 66, in __aenter__
await self.connect()
File "/Users/user/Projects/python-binance/binance/streams.py", line 94, in connect
await self._after_connect()
File "/Users/user/Projects/python-binance/binance/streams.py", line 250, in _after_connect
self._start_socket_timer()
File "/Users/user/Projects/python-binance/binance/streams.py", line 256, in _start_socket_timer
self._keepalive_socket()
self._args = None
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
This PR delays creation of coroutine after timeout.
Though
asyncio.create_task
is run after timeout,self._keepalive_socket()
is run right after connect. When the socket is unexpectedly canceled, this happens never-awaited coroutine error.This PR delays creation of coroutine after timeout.