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
We should switch our threadpool code around so that on Python 3.7+ it always runs in the same contextvars context.
We probably want reusable utility function that looks like this:
try:
importcontextvars# Python 3.7+ only.exceptImportError:
contextvars=Noneasyncdefrun_in_threadpool(func, *args, **kwargs):
loop=asyncio.get_event_loop()
ifcontextvarsisnotNone:
# Ensure we run in the same contextcontext=contextvars.copy_context()
func=functools.partial(context.run, *args, **kwargs)
args= []
elifkwargs:
# loop.run_in_executor doesn't accept 'kwargs', so bind them in herefunc=functools.partial(func, **kwargs)
returnawaitloop.run_in_executor(None, func, *args)
We should also propose the same for Responder. (I don't think that Quart supports sync views, so it's less of an issue there)
The text was updated successfully, but these errors were encountered:
See https://github.com/encode/sentry-asgi and getsentry/sentry-python#162 (comment)
We should switch our threadpool code around so that on Python 3.7+ it always runs in the same
contextvars
context.We probably want reusable utility function that looks like this:
We should also propose the same for Responder. (I don't think that Quart supports sync views, so it's less of an issue there)
The text was updated successfully, but these errors were encountered: