-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error asyncio.exceptions.InvalidStateError: invalid state on connection_lost #36
Comments
Hi! If possible could you provide some more info on how it could be reproduced? Maybe some code snippets on how you setup connection or general connection lifecycle in your app? I understand that it could be hard to reproduce, but still may be some clues. |
Hi! I'll try. We use async connection pool (asyncio_connection_pool) with asynctnt to reuse connections and speed up interaction. Connection pool strategy looks like this:
asyncio_connection_pool don't have an option for timeout on get_connection function.
Then this wrapper is used in standart way:
|
Configuration values are: |
Found this place in source Connection.py: What if while tr.close() (docs say that it works asynchronously) we already create new protocol and call disconnect on it. |
Hi @golubovai ! Sorry for the delay - got carried away with other stuff. I tried to reproduce the error - still no luck :( def connection_is_closed(self, conn: asynctnt.Connection):
return conn.state == ConnectionState.DISCONNECTED This conn.state seems much more accurate to what the end-user (you) expect for the connection to be connected or disconnected. |
Get error on production server:
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 69, in uvloop.loop.Handle._run
File "uvloop/handles/basetransport.pyx", line 169, in uvloop.loop.UVBaseTransport._call_connection_lost
File "asynctnt/iproto/coreproto.pyx", line 185, in asynctnt.iproto.protocol.CoreProtocol.connection_lost
File "asynctnt/iproto/protocol.pyx", line 413, in asynctnt.iproto.protocol.BaseProtocol._on_connection_lost
File "/usr/local/lib/python3.12/site-packages/asynctnt/connection.py", line 174, in connection_lost
self._disconnect_waiter.set_result(True)
asyncio.exceptions.InvalidStateError: invalid state
After this no connections could be established.
version 2.2.1
python 3.12
Maybe this change will be sufficient:
if self._disconnect_waiter: -> if self._disconnect_waiter and not self._disconnect_waiter.done():
The text was updated successfully, but these errors were encountered: