File tree Expand file tree Collapse file tree 2 files changed +2
-14
lines changed
Expand file tree Collapse file tree 2 files changed +2
-14
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import asyncio
4- import contextvars
54import http
65import logging
76from typing import Any , Callable , Literal , cast
@@ -248,12 +247,7 @@ def handle_events(self) -> None:
248247 message_event = asyncio .Event (),
249248 on_response = self .on_response_complete ,
250249 )
251- # For the asyncio loop, we need to explicitly start with an empty context
252- # as it can be polluted from previous ASGI runs.
253- # See https://github.com/python/cpython/issues/140947 for details.
254- task = contextvars .Context ().run (self .loop .create_task , self .cycle .run_asgi (app ))
255- # TODO: Replace the line above with the line below for Python >= 3.11
256- # task = self.loop.create_task(self.cycle.run_asgi(app), context=contextvars.Context())
250+ task = self .loop .create_task (self .cycle .run_asgi (app ))
257251 task .add_done_callback (self .tasks .discard )
258252 self .tasks .add (task )
259253
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import asyncio
4- import contextvars
54import http
65import logging
76import re
@@ -288,12 +287,7 @@ def on_headers_complete(self) -> None:
288287 )
289288 if existing_cycle is None or existing_cycle .response_complete :
290289 # Standard case - start processing the request.
291- # For the asyncio loop, we need to explicitly start with an empty context
292- # as it can be polluted from previous ASGI runs.
293- # See https://github.com/python/cpython/issues/140947 for details.
294- task = contextvars .Context ().run (self .loop .create_task , self .cycle .run_asgi (app ))
295- # TODO: Replace the line above with the line below for Python >= 3.11
296- # task = self.loop.create_task(self.cycle.run_asgi(app), context=contextvars.Context())
290+ task = self .loop .create_task (self .cycle .run_asgi (app ))
297291 task .add_done_callback (self .tasks .discard )
298292 self .tasks .add (task )
299293 else :
You can’t perform that action at this time.
0 commit comments