1
"""Trio - A friendly Python library for async concurrency and I/O
2
"""
3

4
# General layout:
5
#
6
# trio/_core/... is the self-contained core library. It does various
7
# shenanigans to export a consistent "core API", but parts of the core API are
8
# too low-level to be recommended for regular use.
9
#
10
# trio/*.py define a set of more usable tools on top of this. They import from
11
# trio._core and from each other.
12
#
13
# This file pulls together the friendly public API, by re-exporting the more
14
# innocuous bits of the _core API + the higher-level tools from trio/*.py.
15

16 27
from ._version import __version__
17

18 27
from ._core import (
19
    TrioInternalError,
20
    RunFinishedError,
21
    WouldBlock,
22
    Cancelled,
23
    BusyResourceError,
24
    ClosedResourceError,
25
    MultiError,
26
    run,
27
    open_nursery,
28
    CancelScope,
29
    current_effective_deadline,
30
    TASK_STATUS_IGNORED,
31
    current_time,
32
    BrokenResourceError,
33
    EndOfChannel,
34
    Nursery,
35
)
36

37 27
from ._timeouts import (
38
    move_on_at,
39
    move_on_after,
40
    sleep_forever,
41
    sleep_until,
42
    sleep,
43
    fail_at,
44
    fail_after,
45
    TooSlowError,
46
)
47

48 27
from ._sync import (
49
    Event,
50
    CapacityLimiter,
51
    Semaphore,
52
    Lock,
53
    StrictFIFOLock,
54
    Condition,
55
)
56

57 27
from ._highlevel_generic import aclose_forcefully, StapledStream
58

59 27
from ._channel import (
60
    open_memory_channel,
61
    MemorySendChannel,
62
    MemoryReceiveChannel,
63
)
64

65 27
from ._signals import open_signal_receiver
66

67 27
from ._highlevel_socket import SocketStream, SocketListener
68

69 27
from ._file_io import open_file, wrap_file
70

71 27
from ._path import Path
72

73 27
from ._subprocess import Process, open_process, run_process
74

75 27
from ._ssl import SSLStream, SSLListener, NeedHandshakeError
76

77 27
from ._highlevel_serve_listeners import serve_listeners
78

79 27
from ._highlevel_open_tcp_stream import open_tcp_stream
80

81 27
from ._highlevel_open_tcp_listeners import open_tcp_listeners, serve_tcp
82

83 27
from ._highlevel_open_unix_stream import open_unix_socket
84

85 27
from ._highlevel_ssl_helpers import (
86
    open_ssl_over_tcp_stream,
87
    open_ssl_over_tcp_listeners,
88
    serve_ssl_over_tcp,
89
)
90

91 27
from ._deprecate import TrioDeprecationWarning
92

93
# Submodules imported by default
94 27
from . import lowlevel
95 27
from . import socket
96 27
from . import abc
97 27
from . import from_thread
98 27
from . import to_thread
99

100
# Not imported by default, but mentioned here so static analysis tools like
101
# pylint will know that it exists.
102
if False:
103
    from . import testing
104

105 27
from . import _deprecate
106

107 27
_deprecate.enable_attribute_deprecations(__name__)
108

109
# Having the public path in .__module__ attributes is important for:
110
# - exception names in printed tracebacks
111
# - sphinx :show-inheritance:
112
# - deprecation warnings
113
# - pickle
114
# - probably other stuff
115 27
from ._util import fixup_module_metadata
116

117 27
fixup_module_metadata(__name__, globals())
118 27
fixup_module_metadata(lowlevel.__name__, lowlevel.__dict__)
119 27
fixup_module_metadata(socket.__name__, socket.__dict__)
120 27
fixup_module_metadata(abc.__name__, abc.__dict__)
121 27
fixup_module_metadata(from_thread.__name__, from_thread.__dict__)
122 27
fixup_module_metadata(to_thread.__name__, to_thread.__dict__)
123 27
del fixup_module_metadata

Read our documentation on viewing source code .

Loading