[issue44306] asyncio.from_thread
Thomas Grainger
report at bugs.python.org
Thu Jun 3 18:08:45 EDT 2021
New submission from Thomas Grainger <tagrain at gmail.com>:
create a asyncio.from_thread shortcut to run async functions from a thread started with asyncio.to_thread
```
def from_thread(async_func, /, *args, **kwargs):
"""Synchronously run function *async_func* in the event loop thread.
Any *args and **kwargs supplied for this function are directly passed
to *func*. Also, the current :class:`contextvars.Context` is propogated,
allowing context variables from the main thread to be accessed in the
separate thread.
Return a concurrent.futures.Future to wait for the result from the event
loop thread.
```
----------
components: asyncio
messages: 395054
nosy: asvetlov, graingert, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.from_thread
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44306>
_______________________________________
More information about the Python-bugs-list
mailing list