1
"""
2
This namespace represents low-level functionality not intended for daily use,
3
but useful for extending Trio's functionality.
4
"""
5

6 27
import select as _select
7 27
import sys
8 27
import typing as _t
9

10
# This is the union of a subset of trio/_core/ and some things from trio/*.py.
11
# See comments in trio/__init__.py for details. To make static analysis easier,
12
# this lists all possible symbols from trio._core, and then we prune those that
13
# aren't available on this system. After that we add some symbols from trio/*.py.
14

15
# Generally available symbols
16 27
from ._core import (
17
    cancel_shielded_checkpoint,
18
    Abort,
19
    wait_task_rescheduled,
20
    enable_ki_protection,
21
    disable_ki_protection,
22
    currently_ki_protected,
23
    Task,
24
    checkpoint,
25
    current_task,
26
    ParkingLot,
27
    UnboundedQueue,
28
    RunVar,
29
    TrioToken,
30
    current_trio_token,
31
    temporarily_detach_coroutine_object,
32
    permanently_detach_coroutine_object,
33
    reattach_detached_coroutine_object,
34
    current_statistics,
35
    reschedule,
36
    remove_instrument,
37
    add_instrument,
38
    current_clock,
39
    current_root_task,
40
    checkpoint_if_cancelled,
41
    spawn_system_task,
42
    wait_readable,
43
    wait_writable,
44
    notify_closing,
45
    start_thread_soon,
46
    start_guest_run,
47
)
48

49 27
if sys.platform == "win32":
50
    # Windows symbols
51 11
    from ._core import (
52
        current_iocp,
53
        register_with_iocp,
54
        wait_overlapped,
55
        monitor_completion_key,
56
        readinto_overlapped,
57
        write_overlapped,
58
    )
59 11
    from ._wait_for_object import WaitForSingleObject
60
else:
61
    # Unix symbols
62 16
    from ._unix_pipes import FdStream
63

64
    # Kqueue-specific symbols
65 27
    if sys.platform != "linux" and (_t.TYPE_CHECKING or not hasattr(_select, "epoll")):
66 4
        from ._core import (
67
            current_kqueue,
68
            monitor_kevent,
69
            wait_kevent,
70
        )
71

72 27
del sys

Read our documentation on viewing source code .

Loading