You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
contextvars.Context not activated for connection_made() #305
Code works as expected on asyncio loop (var has value in handler) but fails with uvloop. I tracked difference up to connection_made():
File "uvloop/cbhandles.pyx", line 73, in uvloop.loop.Handle._run
File "uvloop/handles/tcp.pyx", line 153, in uvloop.loop.TCPTransport._call_connection_made
File "uvloop/handles/basetransport.pyx", line 134, in uvloop.loop.UVBaseTransport._call_connection_made
File "uvloop/handles/basetransport.pyx", line 131, in uvloop.loop.UVBaseTransport._call_connection_made
File "aiohttp/web_protocol.py", line 223, in connection_made
There is similar difference in UVStreamHandler._on_listen:
Context not being restored for protocol_factory call is what causing problems. python's asyncio copies current context (by creating callback handle) when creating listen() handler:
Activity
versusvoid commentedon Dec 18, 2019
Context not being restored for protocol_factory call is what causing problems. python's asyncio copies current context (by creating callback handle) when creating
listen()handler:https://github.com/python/cpython/blob/fa919fdf2583bdfead1df00e842f24f30b2a34bf/Lib/asyncio/selector_events.py#L252
uvloop simply calls
UVStreamHandler._on_listenfrom libuv1st1 commentedon Jan 14, 2020
Yes, this is a bug.
1st1 commentedon Mar 17, 2020
This PR needs to be considered as part of this issue, basically #306
Add context support in UVHandle and children
Restore context on listen in UVStreamServer. Fix MagicStack#305
Restore context on listen in UVStreamServer. Fix MagicStack#305
Restore context on listen in UVStreamServer. Fix MagicStack#305
Restore context on listen in UVStreamServer. Fix MagicStack#305