Skip to content

Commit

Permalink
Pass contextvars to threadpool executor
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeSneyders committed Dec 23, 2022
1 parent f6d86c7 commit 6347403
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion a2wsgi/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
sender = None
try:
sender = self.loop.create_task(self.sender(send))
context = contextvars.copy_context()
func = functools.partial(context.run, self.wsgi)
await self.loop.run_in_executor(
self.executor, self.wsgi, environ, self.start_response
self.executor, func, environ, self.start_response
)
self.send_queue.append(None)
self.send_event.set()
Expand Down

0 comments on commit 6347403

Please sign in to comment.