Server IP : 85.214.239.14 / Your IP : 18.222.167.85 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/proc/2/root/proc/2/cwd/lib/python3/dist-packages/anyio/ |
Upload File : |
from typing import Callable, Optional, TypeVar from warnings import warn from ._core._eventloop import get_asynclib from .abc import CapacityLimiter T_Retval = TypeVar("T_Retval") async def run_sync( func: Callable[..., T_Retval], *args: object, cancellable: bool = False, limiter: Optional[CapacityLimiter] = None ) -> T_Retval: """ Call the given function with the given arguments in a worker thread. If the ``cancellable`` option is enabled and the task waiting for its completion is cancelled, the thread will still run its course but its return value (or any raised exception) will be ignored. :param func: a callable :param args: positional arguments for the callable :param cancellable: ``True`` to allow cancellation of the operation :param limiter: capacity limiter to use to limit the total amount of threads running (if omitted, the default limiter is used) :return: an awaitable that yields the return value of the function. """ return await get_asynclib().run_sync_in_worker_thread( func, *args, cancellable=cancellable, limiter=limiter ) async def run_sync_in_worker_thread( func: Callable[..., T_Retval], *args: object, cancellable: bool = False, limiter: Optional[CapacityLimiter] = None ) -> T_Retval: warn( "run_sync_in_worker_thread() has been deprecated, use anyio.to_thread.run_sync() instead", DeprecationWarning, ) return await run_sync(func, *args, cancellable=cancellable, limiter=limiter) def current_default_thread_limiter() -> CapacityLimiter: """ Return the capacity limiter that is used by default to limit the number of concurrent threads. :return: a capacity limiter object """ return get_asynclib().current_default_thread_limiter() def current_default_worker_thread_limiter() -> CapacityLimiter: warn( "current_default_worker_thread_limiter() has been deprecated, " "use anyio.to_thread.current_default_thread_limiter() instead", DeprecationWarning, ) return current_default_thread_limiter()