trio の API リファレンス
trio (python-trio/trio) の公開 API 156 件 —— クラス 38、関数 48、メソッド 70。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: python-trio/trio
| 種別 | 件数 |
|---|---|
| クラス | 38 |
| 関数 | 48 |
| メソッド | 70 |
API 一覧
method
src.trio._abc.AsyncResource.aclose() -> NoneClose this resource, possibly blocking.
class
src.trio._abc.ChannelA standard interface for interacting with bidirectional channels.
class
src.trio._abc.ClockThe interface for custom run loop clocks.
method
src.trio._abc.Clock.current_time() -> floatReturn the current time, according to this clock.
method
src.trio._abc.Clock.deadline_to_sleep_time(deadline:float) -> floatCompute the real time until the given deadline.
method
src.trio._abc.Clock.start_clock() -> NoneDo any setup this clock might need.
class
src.trio._abc.InstrumentThe interface for run loop instrumentation.
method
src.trio._abc.Instrument.after_io_wait(timeout:float) -> NoneCalled after handling pending I/O.
method
src.trio._abc.Instrument.after_run() -> NoneCalled just before :func:`trio.run` returns.
method
src.trio._abc.Instrument.after_task_step(task:Task) -> NoneCalled when we return to the main run loop after a task has yielded.
method
src.trio._abc.Instrument.before_io_wait(timeout:float) -> NoneCalled before blocking to wait for I/O readiness.
method
src.trio._abc.Instrument.before_run() -> NoneCalled at the beginning of :func:`trio.run`.
method
src.trio._abc.Instrument.before_task_step(task:Task) -> NoneCalled immediately before we resume running the given task.
method
src.trio._abc.Instrument.task_exited(task:Task) -> NoneCalled when the given task exits.
method
src.trio._abc.Instrument.task_scheduled(task:Task) -> NoneCalled when the given task becomes runnable.
method
src.trio._abc.Instrument.task_spawned(task:Task) -> NoneCalled when the given task is created.
class
src.trio._abc.ListenerA standard interface for listening for incoming connections.
class
src.trio._abc.ReceiveStreamA standard interface for receiving data on a byte stream.
method
src.trio._abc.SendChannel.send(value:SendType) -> NoneAttempt to send an object through the channel, blocking if necessary.
class
src.trio._abc.SendStreamA standard interface for sending data on a byte stream.
method
src.trio._abc.SendStream.send_all(data:bytes | bytearray | memoryview) -> NoneSends the given data through the stream, blocking if necessary.
class
src.trio._channel.MemoryReceiveChannelA memory channel endpoint for receiving Python objects.
method
src.trio._channel.MemoryReceiveChannel.aclose() -> NoneClose this receive channel object asynchronously.
method
src.trio._channel.MemoryReceiveChannel.clone() -> MemoryReceiveChannel[ReceiveType]Clone this receive channel object.
method
src.trio._channel.MemoryReceiveChannel.close() -> NoneClose this receive channel object synchronously.
class
src.trio._channel.MemorySendChannelA memory channel endpoint for sending Python objects.
method
src.trio._channel.MemorySendChannel.aclose() -> NoneClose this send channel object asynchronously.
method
src.trio._channel.MemorySendChannel.clone() -> MemorySendChannel[SendType]Clone this send channel object.
method
src.trio._channel.MemorySendChannel.close() -> NoneClose this send channel object synchronously.
method
src.trio._channel.MemorySendChannel.send(value:SendType) -> NoneSee `SendChannel.send <trio.abc.SendChannel.send>`.
class
src.trio._core._exceptions.WouldBlockRaised by ``X_nowait`` functions if ``X`` would block.
func
src.trio._core._generated_io_epoll.notify_closing(fd:int | _HasFileNo) -> NoneNotify waiters of the given object that it will be closed.
func
src.trio._core._generated_io_epoll.wait_readable(fd:int | _HasFileNo) -> NoneBlock until the kernel reports that the given object is readable.
func
src.trio._core._generated_io_epoll.wait_writable(fd:int | _HasFileNo) -> NoneBlock until the kernel reports that the given object is writable.
func
src.trio._core._generated_io_kqueue.notify_closing(fd:int | _HasFileNo) -> NoneNotify waiters of the given object that it will be closed.
func
src.trio._core._generated_io_windows.notify_closing(handle:Handle | int | _HasFileNo) -> NoneNotify waiters of the given object that it will be closed.
func
src.trio._core._generated_run.current_clock() -> ClockReturns the current :class:`~trio.abc.Clock`.
func
src.trio._core._generated_run.current_root_task() -> Task | NoneReturns the current root :class:`Task`.
func
src.trio._core._generated_run.reschedule(task:Task, next_send:outcome.Outcome[object]=_NO_SEND) -> NoneReschedule the given task with the given :class:`outcome.Outcome`.
func
src.trio._core._generated_run.spawn_system_task(async_fn:Callable[[Unpack[PosArgT]], Awaitable[object]], *name:object=None, *context:contextvars.Context | None=None, *args:Unpack[PosArgT]) -> TaskSpawn a "system" task.
func
src.trio._core._generated_run.wait_all_tasks_blocked(cushion:float=0.0) -> NoneBlock until there are no runnable tasks.
class
src.trio._core._instrumentation.InstrumentsA collection of `trio.abc.Instrument` organized by hook.
method
src.trio._core._instrumentation.Instruments.call(hookname:str, *args:object) -> NoneCall hookname(*args) on each applicable instrument.
func
src.trio._core._ki.disable_ki_protection(f:_T_supports_code) -> _T_supports_codeDecorator to disable KI protection.
func
src.trio._core._ki.enable_ki_protection(f:_T_supports_code) -> _T_supports_codeDecorator to enable KI protection.
class
src.trio._core._local.RunVarThe run-local variant of a context variable.
method
src.trio._core._local.RunVar.get(default:T | type[_NoValue]=_NoValue) -> TGets the value of this :class:`RunVar` for the current run call.
method
src.trio._core._local.RunVar.set(value:T) -> RunVarToken[T]Sets the value of this :class:`RunVar` for this current run call.
class
src.trio._core._mock_clock.MockClockA user-controllable clock suitable for writing tests.
method
src.trio._core._mock_clock.MockClock.jump(seconds:float) -> NoneManually advance the clock by the given number of seconds.
class
src.trio._core._parking_lot.ParkingLotA fair wait queue with cancellation and requeuing.
method
src.trio._core._parking_lot.ParkingLot.break_lot(task:Task | None=None) -> NoneBreak this lot, with ``task`` noted as the task that broke it.
method
src.trio._core._parking_lot.ParkingLot.unpark(*count:int | float=1) -> list[Task]Unpark one or more tasks.
method
src.trio._core._parking_lot.ParkingLot.unpark_all() -> list[Task]Unpark all parked tasks.
func
src.trio._core._parking_lot.add_parking_lot_breaker(task:Task, lot:ParkingLot) -> NoneRegister a task as a breaker for a lot.
func
src.trio._core._parking_lot.remove_parking_lot_breaker(task:Task, lot:ParkingLot) -> NoneDeregister a task as a breaker for a lot.
method
src.trio._core._run.CancelScope.cancel(reason:str | None=None) -> NoneCancels this scope immediately.
method
src.trio._core._run.CancelScope.cancel_called() -> boolReadonly :class:`bool`.
method
src.trio._core._run.CancelScope.deadline() -> floatRead-write, :class:`float`.
method
src.trio._core._run.CancelScope.is_relative() -> bool | NoneReturns None after entering.
method
src.trio._core._run.CancelScope.relative_deadline() -> floatRead-write, :class:`float`.
method
src.trio._core._run.CancelScope.shield() -> boolRead-write, :class:`bool`, default :data:`False`.
class
src.trio._core._run.DeadlinesA container of deadlined cancel scopes.
class
src.trio._core._run.NurseryA context which may be used to spawn (or cancel) child tasks.
method
src.trio._core._run.Nursery.start(async_fn:Callable[..., Awaitable[object]], *name:object=None, *args:object) -> AnyCreates and initializes a child task.
class
src.trio._core._run.NurseryManagerNursery context manager.
class
src.trio._core._run.RunStatisticsAn object containing run-loop-level debugging information.
method
src.trio._core._run.Runner.current_clock() -> ClockReturns the current :class:`~trio.abc.Clock`.
method
src.trio._core._run.Runner.current_root_task() -> Task | NoneReturns the current root :class:`Task`.
method
src.trio._core._run.Runner.spawn_system_task(async_fn:Callable[[Unpack[PosArgT]], Awaitable[object]], *name:object=None, *context:contextvars.Context | None=None, *args:Unpack[PosArgT]) -> TaskSpawn a "system" task.
method
src.trio._core._run.Runner.wait_all_tasks_blocked(cushion:float=0.0) -> NoneBlock until there are no runnable tasks.
method
src.trio._core._run.Task.child_nurseries() -> list[Nursery]The nurseries this task contains.
func
src.trio._core._run.checkpoint() -> NoneA pure :ref:`checkpoint <checkpoints>`.
func
src.trio._core._run.current_task() -> TaskReturn the :class:`Task` object representing the current task.
func
src.trio._core._run.in_trio_run() -> boolCheck whether we are in a Trio run.
func
src.trio._core._run.in_trio_task() -> boolCheck whether we are in a Trio task.
func
src.trio._core._tests.type_tests.nursery_start.check_start_soon(nursery:Nursery) -> Nonestart_soon() functionality.
func
src.trio._core._tests.type_tests.nursery_start.task_pos_or_kw(value:str, task_status:TaskStatus[int]) -> NoneCheck a function which doesn't use the *-syntax works.
func
src.trio._core._tests.type_tests.nursery_start.task_requires_start(*task_status:TaskStatus[str]) -> NoneCheck a function requiring start() to be used.
func
src.trio._core._traps.cancel_shielded_checkpoint() -> NoneIntroduce a schedule point, but not a cancel point.
func
src.trio._core._traps.wait_task_rescheduled(abort_func:Callable[[RaiseCancelT], Abort]) -> AnyPut the current task to sleep, with cancellation support.
class
src.trio._core._unbounded_queue.UnboundedQueueStatisticsAn object containing debugging information.
func
src.trio._core._windows_cffi.handle_array(count:int) -> HandleArrayMake an array of handles.
class
src.trio._deprecate.TrioDeprecationWarningWarning emitted if you use deprecated Trio functionality.
class
src.trio._dtls.DTLSChannelA DTLS connection.
method
src.trio._dtls.DTLSChannel.aclose() -> NoneClose this connection, but asynchronously.
method
src.trio._dtls.DTLSChannel.close() -> NoneClose this connection.
method
src.trio._dtls.DTLSChannel.do_handshake(*initial_retransmit_timeout:float=1.0) -> NonePerform the handshake.
method
src.trio._dtls.DTLSChannel.send(data:bytes) -> NoneSend a packet of data, securely.
class
src.trio._dtls.DTLSEndpointA DTLS endpoint.
method
src.trio._dtls.DTLSEndpoint.close() -> NoneClose this socket, and all associated DTLS connections.
method
src.trio._dtls.DTLSEndpoint.connect(address:tuple[str, int], ssl_context:SSL.Context) -> DTLSChannelInitiate an outgoing DTLS connection.
method
src.trio._highlevel_socket.SocketListener.accept() -> SocketStreamAccept an incoming connection.
method
src.trio._highlevel_socket.SocketListener.aclose() -> NoneClose this listener and its underlying socket.
func
src.trio._signals.get_pending_signal_count(rec:AsyncIterator[int]) -> intHelper for tests, not public or otherwise used.
func
src.trio._signals.open_signal_receiver(*signals:signal.Signals | int) -> Generator[AsyncIterator[int], None, None]A context manager for catching signals.
method
src.trio._socket.SocketType.is_readable() -> boolReturn True if the socket is readable.
func
src.trio._socket.fromshare(info:bytes) -> SocketTypeLike :func:`socket.fromshare`, but returns a Trio socket object.
func
src.trio._socket.getnameinfo(sockaddr:tuple[str, int] | tuple[str, int, int, int], flags:int) -> tuple[str, str]Look up a name given a numeric address.
func
src.trio._socket.getprotobyname(name:str) -> intLook up a protocol number by name.
func
src.trio._socket.set_custom_hostname_resolver(hostname_resolver:HostnameResolver | None) -> HostnameResolver | NoneSet a custom hostname resolver.
func
src.trio._socket.set_custom_socket_factory(socket_factory:SocketFactory | None) -> SocketFactory | NoneSet a custom socket object factory.
class
src.trio._ssl.SSLListenerA :class:`~trio.abc.Listener` for SSL/TLS-encrypted servers.
method
src.trio._ssl.SSLListener.aclose() -> NoneClose the transport listener.
class
src.trio._ssl.SSLStreamEncrypted communication using SSL/TLS.
method
src.trio._ssl.SSLStream.do_handshake() -> NoneEnsure that the initial handshake has completed.
method
src.trio._ssl.SSLStream.send_all(data:bytes | bytearray | memoryview) -> NoneEncrypt some data and then send it on the underlying transport.
class
src.trio._subprocess.GeneralProcessArgsArguments shared between all runs.
class
src.trio._subprocess.HasFilenoRepresents any file-like object that has a file descriptor.
class
src.trio._subprocess.ProcessA child process.
method
src.trio._subprocess.Process.kill() -> NoneImmediately terminate the process.
method
src.trio._subprocess.Process.send_signal(sig:signal.Signals | int) -> NoneSend signal ``sig`` to the process.
method
src.trio._subprocess.Process.terminate() -> NoneTerminate the process, politely if possible.
method
src.trio._subprocess.Process.wait() -> intBlock until the process exits.
class
src.trio._subprocess.UnixProcessArgs3_10Arguments shared between all Unix runs.
class
src.trio._subprocess.UnixProcessArgs3_11Arguments shared between all Unix runs on 3.11+.
class
src.trio._subprocess.UnixRunProcessArgsArguments for run_process on Unix with 3.11+
class
src.trio._subprocess.UnixRunProcessMixinArguments unique to run_process on Unix.
class
src.trio._subprocess.WindowsProcessArgsArguments shared between all Windows runs.
func
src.trio._subprocess.open_process(command:StrOrBytesPath | Sequence[StrOrBytesPath], *stdin:int | HasFileno | None=None, **kwargs:Unpack[WindowsProcessArgs]) -> trio.ProcessExecute a child program in a new process.
func
src.trio._subprocess_platform.wait_child_exiting(process:_subprocess.Process) -> NoneBlock until the child process managed by ``process`` is exiting.
class
src.trio._sync.CapacityLimiterStatisticsAn object containing debugging information.
method
src.trio._sync.Condition.acquire() -> NoneAcquire the underlying lock, blocking if necessary.
method
src.trio._sync.Condition.acquire_nowait() -> NoneAttempt to acquire the underlying lock, without blocking.
method
src.trio._sync.Condition.locked() -> boolCheck whether the underlying lock is currently held.
method
src.trio._sync.Condition.notify(n:int=1) -> NoneWake one or more tasks that are blocked in :meth:`wait`.
method
src.trio._sync.Condition.notify_all() -> NoneWake all tasks that are currently blocked in :meth:`wait`.
method
src.trio._sync.Condition.release() -> NoneRelease the underlying lock.
method
src.trio._sync.Condition.statistics() -> ConditionStatisticsReturn an object containing debugging information.
class
src.trio._sync.ConditionStatisticsAn object containing debugging information for a Condition.
method
src.trio._sync.Event.is_set() -> boolReturn the current value of the internal flag.
method
src.trio._sync.Event.statistics() -> EventStatisticsReturn an object containing debugging information.
method
src.trio._sync.Event.wait() -> NoneBlock until the internal flag value becomes True.
class
src.trio._sync.EventStatisticsAn object containing debugging information.
class
src.trio._sync.LockStatisticsAn object containing debugging information for a Lock.
method
src.trio._sync.Semaphore.max_value() -> int | NoneThe maximum allowed value.
method
src.trio._sync.Semaphore.statistics() -> ParkingLotStatisticsReturn an object containing debugging information.
method
src.trio._sync.Semaphore.value() -> intThe current value of the semaphore.
func
src.trio._tests.type_tests.path.operator_checks(text:str, tpath:trio.Path, ppath:pathlib.Path) -> NoneVerify operators produce the right results.
func
src.trio._threads.wait_all_threads_completed() -> NoneWait until no threads are still running tasks.
func
src.trio._timeouts.sleep(seconds:float) -> NonePause execution of the current task for the given number of seconds.
func
src.trio._timeouts.sleep_until(deadline:float) -> NonePause execution of the current task until the given time.
func
src.trio._tools.gen_exports.get_public_methods(tree:ast.AST) -> Iterator[ast.FunctionDef | ast.AsyncFunctionDef]Return a list of methods marked as public.
func
src.trio._tools.gen_exports.is_public(node:ast.AST) -> TypeGuard[ast.FunctionDef | ast.AsyncFunctionDef]Check if the AST node has a _public decorator
func
src.trio._tools.gen_exports.run_black(file:File, source:str) -> tuple[bool, str]Run black on the specified file.
func
src.trio._tools.gen_exports.run_linters(file:File, source:str) -> strFormat the specified file using black and ruff.
func
src.trio._tools.gen_exports.run_ruff(file:File, source:str) -> tuple[bool, str]Run ruff on the specified file.
class
src.trio._tools.mypy_annotate.ResultAccumulated results, used as a dict key to deduplicate.
func
src.trio._tools.mypy_annotate.export(results:dict[Result, list[str]]) -> NoneDisplay the collected results.
func
src.trio._tools.mypy_annotate.main(argv:list[str]) -> NoneLook for error messages, and convert the format.
func
src.trio._tools.sync_requirements.update_requirements(requirements:Path, version_data:dict[str, str]) -> boolReturn if updated requirements file.
class
src.trio._util.NoPublicConstructorMetaclass that ensures a private constructor.
func
src.trio._util.is_main_thread() -> boolAttempt to reliably check if we are in the main thread.
func
src.trio._wait_for_object.WaitForMultipleObjects_sync(*handles:int | CData) -> NoneWait for any of the given Windows handles to be signaled.
func
src.trio._wait_for_object.WaitForSingleObject(obj:int | CData) -> NoneAsync and cancellable variant of WaitForSingleObject.
class
src.trio._windows_pipes.PipeReceiveStreamRepresents a receive stream over an os.pipe object.
この情報について
掲載しているシグネチャは python-trio/trio の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。