/opt/alt/python311/lib64/python3.11/asyncio
"""High-level support for working with threads in asyncio""" import functools import contextvars from . import events __all__ = "to_thread", async def to_thread(func, /, *args, **kwargs): """Asynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. """ loop = events.get_running_loop() ctx = contextvars.copy_context() func_call = functools.partial(ctx.run, func, *args, **kwargs) return await loop.run_in_executor(None, func_call)
.
Edit
..
Edit
__init__.py
Edit
__main__.py
Edit
__pycache__
Edit
base_events.py
Edit
base_futures.py
Edit
base_subprocess.py
Edit
base_tasks.py
Edit
constants.py
Edit
coroutines.py
Edit
events.py
Edit
exceptions.py
Edit
format_helpers.py
Edit
futures.py
Edit
locks.py
Edit
log.py
Edit
mixins.py
Edit
proactor_events.py
Edit
protocols.py
Edit
queues.py
Edit
runners.py
Edit
selector_events.py
Edit
sslproto.py
Edit
staggered.py
Edit
streams.py
Edit
subprocess.py
Edit
taskgroups.py
Edit
tasks.py
Edit
threads.py
Edit
timeouts.py
Edit
transports.py
Edit
trsock.py
Edit
unix_events.py
Edit
windows_events.py
Edit
windows_utils.py
Edit