@ajksunkang-aios/kgraph-linux-x64 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/bin/kgraph-launcher +15 -3
  2. package/lib/kgraph/scripts/build-bundle.sh +17 -4
  3. package/lib/site-packages/outcome/__init__.py +20 -0
  4. package/lib/site-packages/outcome/_impl.py +239 -0
  5. package/lib/site-packages/outcome/_util.py +33 -0
  6. package/lib/site-packages/outcome/_version.py +7 -0
  7. package/lib/site-packages/outcome/py.typed +0 -0
  8. package/lib/site-packages/outcome-1.3.0.post0.dist-info/INSTALLER +1 -0
  9. package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE +3 -0
  10. package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE.APACHE2 +202 -0
  11. package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE.MIT +20 -0
  12. package/lib/site-packages/outcome-1.3.0.post0.dist-info/METADATA +63 -0
  13. package/lib/site-packages/outcome-1.3.0.post0.dist-info/RECORD +13 -0
  14. package/lib/site-packages/outcome-1.3.0.post0.dist-info/WHEEL +6 -0
  15. package/lib/site-packages/outcome-1.3.0.post0.dist-info/top_level.txt +1 -0
  16. package/lib/site-packages/sniffio/__init__.py +17 -0
  17. package/lib/site-packages/sniffio/_impl.py +95 -0
  18. package/lib/site-packages/sniffio/_tests/__init__.py +0 -0
  19. package/lib/site-packages/sniffio/_tests/test_sniffio.py +84 -0
  20. package/lib/site-packages/sniffio/_version.py +3 -0
  21. package/lib/site-packages/sniffio/py.typed +0 -0
  22. package/lib/site-packages/sniffio-1.3.1.dist-info/INSTALLER +1 -0
  23. package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE +3 -0
  24. package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE.APACHE2 +202 -0
  25. package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE.MIT +20 -0
  26. package/lib/site-packages/sniffio-1.3.1.dist-info/METADATA +104 -0
  27. package/lib/site-packages/sniffio-1.3.1.dist-info/RECORD +14 -0
  28. package/lib/site-packages/sniffio-1.3.1.dist-info/WHEEL +5 -0
  29. package/lib/site-packages/sniffio-1.3.1.dist-info/top_level.txt +1 -0
  30. package/lib/site-packages/sortedcontainers/__init__.py +74 -0
  31. package/lib/site-packages/sortedcontainers/sorteddict.py +812 -0
  32. package/lib/site-packages/sortedcontainers/sortedlist.py +2646 -0
  33. package/lib/site-packages/sortedcontainers/sortedset.py +733 -0
  34. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/INSTALLER +1 -0
  35. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/LICENSE +13 -0
  36. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/METADATA +264 -0
  37. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/RECORD +10 -0
  38. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/WHEEL +6 -0
  39. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/top_level.txt +1 -0
  40. package/lib/site-packages/trio/__init__.py +133 -0
  41. package/lib/site-packages/trio/__main__.py +3 -0
  42. package/lib/site-packages/trio/_abc.py +714 -0
  43. package/lib/site-packages/trio/_channel.py +610 -0
  44. package/lib/site-packages/trio/_core/__init__.py +94 -0
  45. package/lib/site-packages/trio/_core/_asyncgens.py +243 -0
  46. package/lib/site-packages/trio/_core/_concat_tb.py +26 -0
  47. package/lib/site-packages/trio/_core/_entry_queue.py +223 -0
  48. package/lib/site-packages/trio/_core/_exceptions.py +169 -0
  49. package/lib/site-packages/trio/_core/_generated_instrumentation.py +50 -0
  50. package/lib/site-packages/trio/_core/_generated_io_epoll.py +98 -0
  51. package/lib/site-packages/trio/_core/_generated_io_kqueue.py +153 -0
  52. package/lib/site-packages/trio/_core/_generated_io_windows.py +204 -0
  53. package/lib/site-packages/trio/_core/_generated_run.py +269 -0
  54. package/lib/site-packages/trio/_core/_generated_windows_ffi.py +10 -0
  55. package/lib/site-packages/trio/_core/_instrumentation.py +117 -0
  56. package/lib/site-packages/trio/_core/_io_common.py +31 -0
  57. package/lib/site-packages/trio/_core/_io_epoll.py +385 -0
  58. package/lib/site-packages/trio/_core/_io_kqueue.py +292 -0
  59. package/lib/site-packages/trio/_core/_io_windows.py +1036 -0
  60. package/lib/site-packages/trio/_core/_ki.py +271 -0
  61. package/lib/site-packages/trio/_core/_local.py +104 -0
  62. package/lib/site-packages/trio/_core/_mock_clock.py +165 -0
  63. package/lib/site-packages/trio/_core/_parking_lot.py +317 -0
  64. package/lib/site-packages/trio/_core/_run.py +3148 -0
  65. package/lib/site-packages/trio/_core/_run_context.py +15 -0
  66. package/lib/site-packages/trio/_core/_tests/__init__.py +0 -0
  67. package/lib/site-packages/trio/_core/_tests/test_asyncgen.py +339 -0
  68. package/lib/site-packages/trio/_core/_tests/test_cancelled.py +222 -0
  69. package/lib/site-packages/trio/_core/_tests/test_exceptiongroup_gc.py +103 -0
  70. package/lib/site-packages/trio/_core/_tests/test_guest_mode.py +755 -0
  71. package/lib/site-packages/trio/_core/_tests/test_instrumentation.py +315 -0
  72. package/lib/site-packages/trio/_core/_tests/test_io.py +522 -0
  73. package/lib/site-packages/trio/_core/_tests/test_ki.py +703 -0
  74. package/lib/site-packages/trio/_core/_tests/test_local.py +118 -0
  75. package/lib/site-packages/trio/_core/_tests/test_mock_clock.py +193 -0
  76. package/lib/site-packages/trio/_core/_tests/test_parking_lot.py +389 -0
  77. package/lib/site-packages/trio/_core/_tests/test_run.py +3024 -0
  78. package/lib/site-packages/trio/_core/_tests/test_thread_cache.py +227 -0
  79. package/lib/site-packages/trio/_core/_tests/test_tutil.py +13 -0
  80. package/lib/site-packages/trio/_core/_tests/test_unbounded_queue.py +154 -0
  81. package/lib/site-packages/trio/_core/_tests/test_windows.py +305 -0
  82. package/lib/site-packages/trio/_core/_tests/tutil.py +117 -0
  83. package/lib/site-packages/trio/_core/_tests/type_tests/nursery_start.py +79 -0
  84. package/lib/site-packages/trio/_core/_tests/type_tests/run.py +51 -0
  85. package/lib/site-packages/trio/_core/_thread_cache.py +317 -0
  86. package/lib/site-packages/trio/_core/_traps.py +318 -0
  87. package/lib/site-packages/trio/_core/_unbounded_queue.py +163 -0
  88. package/lib/site-packages/trio/_core/_wakeup_socketpair.py +75 -0
  89. package/lib/site-packages/trio/_core/_windows_cffi.py +313 -0
  90. package/lib/site-packages/trio/_deprecate.py +171 -0
  91. package/lib/site-packages/trio/_dtls.py +1380 -0
  92. package/lib/site-packages/trio/_file_io.py +513 -0
  93. package/lib/site-packages/trio/_highlevel_generic.py +125 -0
  94. package/lib/site-packages/trio/_highlevel_open_tcp_listeners.py +251 -0
  95. package/lib/site-packages/trio/_highlevel_open_tcp_stream.py +397 -0
  96. package/lib/site-packages/trio/_highlevel_open_unix_stream.py +65 -0
  97. package/lib/site-packages/trio/_highlevel_serve_listeners.py +148 -0
  98. package/lib/site-packages/trio/_highlevel_socket.py +423 -0
  99. package/lib/site-packages/trio/_highlevel_ssl_helpers.py +180 -0
  100. package/lib/site-packages/trio/_path.py +289 -0
  101. package/lib/site-packages/trio/_repl.py +159 -0
  102. package/lib/site-packages/trio/_signals.py +185 -0
  103. package/lib/site-packages/trio/_socket.py +1326 -0
  104. package/lib/site-packages/trio/_ssl.py +964 -0
  105. package/lib/site-packages/trio/_subprocess.py +1178 -0
  106. package/lib/site-packages/trio/_subprocess_platform/__init__.py +123 -0
  107. package/lib/site-packages/trio/_subprocess_platform/kqueue.py +48 -0
  108. package/lib/site-packages/trio/_subprocess_platform/waitid.py +113 -0
  109. package/lib/site-packages/trio/_subprocess_platform/windows.py +11 -0
  110. package/lib/site-packages/trio/_sync.py +908 -0
  111. package/lib/site-packages/trio/_tests/__init__.py +0 -0
  112. package/lib/site-packages/trio/_tests/astrill-codesigning-cert.cer +0 -0
  113. package/lib/site-packages/trio/_tests/check_type_completeness.py +247 -0
  114. package/lib/site-packages/trio/_tests/module_with_deprecations.py +22 -0
  115. package/lib/site-packages/trio/_tests/pytest_plugin.py +54 -0
  116. package/lib/site-packages/trio/_tests/test_abc.py +72 -0
  117. package/lib/site-packages/trio/_tests/test_channel.py +750 -0
  118. package/lib/site-packages/trio/_tests/test_contextvars.py +56 -0
  119. package/lib/site-packages/trio/_tests/test_deprecate.py +277 -0
  120. package/lib/site-packages/trio/_tests/test_deprecate_strict_exception_groups_false.py +64 -0
  121. package/lib/site-packages/trio/_tests/test_dtls.py +950 -0
  122. package/lib/site-packages/trio/_tests/test_exports.py +626 -0
  123. package/lib/site-packages/trio/_tests/test_fakenet.py +317 -0
  124. package/lib/site-packages/trio/_tests/test_file_io.py +269 -0
  125. package/lib/site-packages/trio/_tests/test_highlevel_generic.py +98 -0
  126. package/lib/site-packages/trio/_tests/test_highlevel_open_tcp_listeners.py +419 -0
  127. package/lib/site-packages/trio/_tests/test_highlevel_open_tcp_stream.py +693 -0
  128. package/lib/site-packages/trio/_tests/test_highlevel_open_unix_stream.py +86 -0
  129. package/lib/site-packages/trio/_tests/test_highlevel_serve_listeners.py +186 -0
  130. package/lib/site-packages/trio/_tests/test_highlevel_socket.py +336 -0
  131. package/lib/site-packages/trio/_tests/test_highlevel_ssl_helpers.py +169 -0
  132. package/lib/site-packages/trio/_tests/test_path.py +279 -0
  133. package/lib/site-packages/trio/_tests/test_repl.py +428 -0
  134. package/lib/site-packages/trio/_tests/test_scheduler_determinism.py +47 -0
  135. package/lib/site-packages/trio/_tests/test_signals.py +186 -0
  136. package/lib/site-packages/trio/_tests/test_socket.py +1253 -0
  137. package/lib/site-packages/trio/_tests/test_ssl.py +1371 -0
  138. package/lib/site-packages/trio/_tests/test_subprocess.py +767 -0
  139. package/lib/site-packages/trio/_tests/test_sync.py +735 -0
  140. package/lib/site-packages/trio/_tests/test_testing.py +682 -0
  141. package/lib/site-packages/trio/_tests/test_testing_raisesgroup.py +1128 -0
  142. package/lib/site-packages/trio/_tests/test_threads.py +1173 -0
  143. package/lib/site-packages/trio/_tests/test_timeouts.py +281 -0
  144. package/lib/site-packages/trio/_tests/test_tracing.py +88 -0
  145. package/lib/site-packages/trio/_tests/test_trio.py +8 -0
  146. package/lib/site-packages/trio/_tests/test_unix_pipes.py +288 -0
  147. package/lib/site-packages/trio/_tests/test_util.py +349 -0
  148. package/lib/site-packages/trio/_tests/test_wait_for_object.py +225 -0
  149. package/lib/site-packages/trio/_tests/test_windows_pipes.py +112 -0
  150. package/lib/site-packages/trio/_tests/tools/__init__.py +0 -0
  151. package/lib/site-packages/trio/_tests/tools/test_gen_exports.py +179 -0
  152. package/lib/site-packages/trio/_tests/tools/test_mypy_annotate.py +140 -0
  153. package/lib/site-packages/trio/_tests/tools/test_sync_requirements.py +80 -0
  154. package/lib/site-packages/trio/_tests/type_tests/check_wraps.py +9 -0
  155. package/lib/site-packages/trio/_tests/type_tests/open_memory_channel.py +4 -0
  156. package/lib/site-packages/trio/_tests/type_tests/path.py +140 -0
  157. package/lib/site-packages/trio/_tests/type_tests/subprocesses.py +23 -0
  158. package/lib/site-packages/trio/_tests/type_tests/task_status.py +29 -0
  159. package/lib/site-packages/trio/_threads.py +610 -0
  160. package/lib/site-packages/trio/_timeouts.py +197 -0
  161. package/lib/site-packages/trio/_tools/__init__.py +0 -0
  162. package/lib/site-packages/trio/_tools/gen_exports.py +401 -0
  163. package/lib/site-packages/trio/_tools/mypy_annotate.py +126 -0
  164. package/lib/site-packages/trio/_tools/sync_requirements.py +98 -0
  165. package/lib/site-packages/trio/_tools/windows_ffi_build.py +220 -0
  166. package/lib/site-packages/trio/_unix_pipes.py +197 -0
  167. package/lib/site-packages/trio/_util.py +385 -0
  168. package/lib/site-packages/trio/_version.py +3 -0
  169. package/lib/site-packages/trio/_wait_for_object.py +67 -0
  170. package/lib/site-packages/trio/_windows_pipes.py +144 -0
  171. package/lib/site-packages/trio/abc.py +23 -0
  172. package/lib/site-packages/trio/from_thread.py +13 -0
  173. package/lib/site-packages/trio/lowlevel.py +95 -0
  174. package/lib/site-packages/trio/py.typed +0 -0
  175. package/lib/site-packages/trio/socket.py +602 -0
  176. package/lib/site-packages/trio/testing/__init__.py +58 -0
  177. package/lib/site-packages/trio/testing/_check_streams.py +570 -0
  178. package/lib/site-packages/trio/testing/_checkpoints.py +69 -0
  179. package/lib/site-packages/trio/testing/_fake_net.py +584 -0
  180. package/lib/site-packages/trio/testing/_memory_streams.py +633 -0
  181. package/lib/site-packages/trio/testing/_network.py +36 -0
  182. package/lib/site-packages/trio/testing/_raises_group.py +1015 -0
  183. package/lib/site-packages/trio/testing/_sequencer.py +87 -0
  184. package/lib/site-packages/trio/testing/_trio_test.py +50 -0
  185. package/lib/site-packages/trio/to_thread.py +4 -0
  186. package/lib/site-packages/trio-0.33.0.dist-info/INSTALLER +1 -0
  187. package/lib/site-packages/trio-0.33.0.dist-info/METADATA +186 -0
  188. package/lib/site-packages/trio-0.33.0.dist-info/RECORD +156 -0
  189. package/lib/site-packages/trio-0.33.0.dist-info/REQUESTED +0 -0
  190. package/lib/site-packages/trio-0.33.0.dist-info/WHEEL +5 -0
  191. package/lib/site-packages/trio-0.33.0.dist-info/entry_points.txt +2 -0
  192. package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE +3 -0
  193. package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE.APACHE2 +202 -0
  194. package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE.MIT +22 -0
  195. package/lib/site-packages/trio-0.33.0.dist-info/top_level.txt +1 -0
  196. package/package.json +1 -1
@@ -0,0 +1,50 @@
1
+ # ***********************************************************
2
+ # ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST ******
3
+ # *************************************************************
4
+ from __future__ import annotations
5
+
6
+ from typing import TYPE_CHECKING
7
+
8
+ from ._ki import enable_ki_protection
9
+ from ._run import GLOBAL_RUN_CONTEXT
10
+
11
+ if TYPE_CHECKING:
12
+ from ._instrumentation import Instrument
13
+
14
+ __all__ = ["add_instrument", "remove_instrument"]
15
+
16
+
17
+ @enable_ki_protection
18
+ def add_instrument(instrument: Instrument) -> None:
19
+ """Start instrumenting the current run loop with the given instrument.
20
+
21
+ Args:
22
+ instrument (trio.abc.Instrument): The instrument to activate.
23
+
24
+ If ``instrument`` is already active, does nothing.
25
+
26
+ """
27
+ try:
28
+ return GLOBAL_RUN_CONTEXT.runner.instruments.add_instrument(instrument)
29
+ except AttributeError:
30
+ raise RuntimeError("must be called from async context") from None
31
+
32
+
33
+ @enable_ki_protection
34
+ def remove_instrument(instrument: Instrument) -> None:
35
+ """Stop instrumenting the current run loop with the given instrument.
36
+
37
+ Args:
38
+ instrument (trio.abc.Instrument): The instrument to de-activate.
39
+
40
+ Raises:
41
+ KeyError: if the instrument is not currently active. This could
42
+ occur either because you never added it, or because you added it
43
+ and then it raised an unhandled exception and was automatically
44
+ deactivated.
45
+
46
+ """
47
+ try:
48
+ return GLOBAL_RUN_CONTEXT.runner.instruments.remove_instrument(instrument)
49
+ except AttributeError:
50
+ raise RuntimeError("must be called from async context") from None
@@ -0,0 +1,98 @@
1
+ # ***********************************************************
2
+ # ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST ******
3
+ # *************************************************************
4
+ from __future__ import annotations
5
+
6
+ import sys
7
+ from typing import TYPE_CHECKING
8
+
9
+ from ._ki import enable_ki_protection
10
+ from ._run import GLOBAL_RUN_CONTEXT
11
+
12
+ if TYPE_CHECKING:
13
+ from .._file_io import _HasFileNo
14
+
15
+ assert not TYPE_CHECKING or sys.platform == "linux"
16
+
17
+
18
+ __all__ = ["notify_closing", "wait_readable", "wait_writable"]
19
+
20
+
21
+ @enable_ki_protection
22
+ async def wait_readable(fd: int | _HasFileNo) -> None:
23
+ """Block until the kernel reports that the given object is readable.
24
+
25
+ On Unix systems, ``fd`` must either be an integer file descriptor,
26
+ or else an object with a ``.fileno()`` method which returns an
27
+ integer file descriptor. Any kind of file descriptor can be passed,
28
+ though the exact semantics will depend on your kernel. For example,
29
+ this probably won't do anything useful for on-disk files.
30
+
31
+ On Windows systems, ``fd`` must either be an integer ``SOCKET``
32
+ handle, or else an object with a ``.fileno()`` method which returns
33
+ an integer ``SOCKET`` handle. File descriptors aren't supported,
34
+ and neither are handles that refer to anything besides a
35
+ ``SOCKET``.
36
+
37
+ :raises trio.BusyResourceError:
38
+ if another task is already waiting for the given socket to
39
+ become readable.
40
+ :raises trio.ClosedResourceError:
41
+ if another task calls :func:`notify_closing` while this
42
+ function is still working.
43
+ """
44
+ try:
45
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_readable(fd)
46
+ except AttributeError:
47
+ raise RuntimeError("must be called from async context") from None
48
+
49
+
50
+ @enable_ki_protection
51
+ async def wait_writable(fd: int | _HasFileNo) -> None:
52
+ """Block until the kernel reports that the given object is writable.
53
+
54
+ See `wait_readable` for the definition of ``fd``.
55
+
56
+ :raises trio.BusyResourceError:
57
+ if another task is already waiting for the given socket to
58
+ become writable.
59
+ :raises trio.ClosedResourceError:
60
+ if another task calls :func:`notify_closing` while this
61
+ function is still working.
62
+ """
63
+ try:
64
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_writable(fd)
65
+ except AttributeError:
66
+ raise RuntimeError("must be called from async context") from None
67
+
68
+
69
+ @enable_ki_protection
70
+ def notify_closing(fd: int | _HasFileNo) -> None:
71
+ """Notify waiters of the given object that it will be closed.
72
+
73
+ Call this before closing a file descriptor (on Unix) or socket (on
74
+ Windows). This will cause any `wait_readable` or `wait_writable`
75
+ calls on the given object to immediately wake up and raise
76
+ `~trio.ClosedResourceError`.
77
+
78
+ This doesn't actually close the object – you still have to do that
79
+ yourself afterwards. Also, you want to be careful to make sure no
80
+ new tasks start waiting on the object in between when you call this
81
+ and when it's actually closed. So to close something properly, you
82
+ usually want to do these steps in order:
83
+
84
+ 1. Explicitly mark the object as closed, so that any new attempts
85
+ to use it will abort before they start.
86
+ 2. Call `notify_closing` to wake up any already-existing users.
87
+ 3. Actually close the object.
88
+
89
+ It's also possible to do them in a different order if that's more
90
+ convenient, *but only if* you make sure not to have any checkpoints in
91
+ between the steps. This way they all happen in a single atomic
92
+ step, so other tasks won't be able to tell what order they happened
93
+ in anyway.
94
+ """
95
+ try:
96
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.notify_closing(fd)
97
+ except AttributeError:
98
+ raise RuntimeError("must be called from async context") from None
@@ -0,0 +1,153 @@
1
+ # ***********************************************************
2
+ # ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST ******
3
+ # *************************************************************
4
+ from __future__ import annotations
5
+
6
+ import sys
7
+ from typing import TYPE_CHECKING
8
+
9
+ from ._ki import enable_ki_protection
10
+ from ._run import GLOBAL_RUN_CONTEXT
11
+
12
+ if TYPE_CHECKING:
13
+ import select
14
+ from collections.abc import Callable
15
+ from contextlib import AbstractContextManager
16
+
17
+ from .. import _core
18
+ from .._file_io import _HasFileNo
19
+ from ._traps import Abort, RaiseCancelT
20
+
21
+ assert not TYPE_CHECKING or sys.platform == "darwin"
22
+
23
+
24
+ __all__ = [
25
+ "current_kqueue",
26
+ "monitor_kevent",
27
+ "notify_closing",
28
+ "wait_kevent",
29
+ "wait_readable",
30
+ "wait_writable",
31
+ ]
32
+
33
+
34
+ @enable_ki_protection
35
+ def current_kqueue() -> select.kqueue:
36
+ """TODO: these are implemented, but are currently more of a sketch than
37
+ anything real. See `#26
38
+ <https://github.com/python-trio/trio/issues/26>`__.
39
+ """
40
+ try:
41
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.current_kqueue()
42
+ except AttributeError:
43
+ raise RuntimeError("must be called from async context") from None
44
+
45
+
46
+ @enable_ki_protection
47
+ def monitor_kevent(
48
+ ident: int, filter: int
49
+ ) -> AbstractContextManager[_core.UnboundedQueue[select.kevent]]:
50
+ """TODO: these are implemented, but are currently more of a sketch than
51
+ anything real. See `#26
52
+ <https://github.com/python-trio/trio/issues/26>`__.
53
+ """
54
+ try:
55
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.monitor_kevent(ident, filter)
56
+ except AttributeError:
57
+ raise RuntimeError("must be called from async context") from None
58
+
59
+
60
+ @enable_ki_protection
61
+ async def wait_kevent(
62
+ ident: int, filter: int, abort_func: Callable[[RaiseCancelT], Abort]
63
+ ) -> Abort:
64
+ """TODO: these are implemented, but are currently more of a sketch than
65
+ anything real. See `#26
66
+ <https://github.com/python-trio/trio/issues/26>`__.
67
+ """
68
+ try:
69
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_kevent(
70
+ ident, filter, abort_func
71
+ )
72
+ except AttributeError:
73
+ raise RuntimeError("must be called from async context") from None
74
+
75
+
76
+ @enable_ki_protection
77
+ async def wait_readable(fd: int | _HasFileNo) -> None:
78
+ """Block until the kernel reports that the given object is readable.
79
+
80
+ On Unix systems, ``fd`` must either be an integer file descriptor,
81
+ or else an object with a ``.fileno()`` method which returns an
82
+ integer file descriptor. Any kind of file descriptor can be passed,
83
+ though the exact semantics will depend on your kernel. For example,
84
+ this probably won't do anything useful for on-disk files.
85
+
86
+ On Windows systems, ``fd`` must either be an integer ``SOCKET``
87
+ handle, or else an object with a ``.fileno()`` method which returns
88
+ an integer ``SOCKET`` handle. File descriptors aren't supported,
89
+ and neither are handles that refer to anything besides a
90
+ ``SOCKET``.
91
+
92
+ :raises trio.BusyResourceError:
93
+ if another task is already waiting for the given socket to
94
+ become readable.
95
+ :raises trio.ClosedResourceError:
96
+ if another task calls :func:`notify_closing` while this
97
+ function is still working.
98
+ """
99
+ try:
100
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_readable(fd)
101
+ except AttributeError:
102
+ raise RuntimeError("must be called from async context") from None
103
+
104
+
105
+ @enable_ki_protection
106
+ async def wait_writable(fd: int | _HasFileNo) -> None:
107
+ """Block until the kernel reports that the given object is writable.
108
+
109
+ See `wait_readable` for the definition of ``fd``.
110
+
111
+ :raises trio.BusyResourceError:
112
+ if another task is already waiting for the given socket to
113
+ become writable.
114
+ :raises trio.ClosedResourceError:
115
+ if another task calls :func:`notify_closing` while this
116
+ function is still working.
117
+ """
118
+ try:
119
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_writable(fd)
120
+ except AttributeError:
121
+ raise RuntimeError("must be called from async context") from None
122
+
123
+
124
+ @enable_ki_protection
125
+ def notify_closing(fd: int | _HasFileNo) -> None:
126
+ """Notify waiters of the given object that it will be closed.
127
+
128
+ Call this before closing a file descriptor (on Unix) or socket (on
129
+ Windows). This will cause any `wait_readable` or `wait_writable`
130
+ calls on the given object to immediately wake up and raise
131
+ `~trio.ClosedResourceError`.
132
+
133
+ This doesn't actually close the object – you still have to do that
134
+ yourself afterwards. Also, you want to be careful to make sure no
135
+ new tasks start waiting on the object in between when you call this
136
+ and when it's actually closed. So to close something properly, you
137
+ usually want to do these steps in order:
138
+
139
+ 1. Explicitly mark the object as closed, so that any new attempts
140
+ to use it will abort before they start.
141
+ 2. Call `notify_closing` to wake up any already-existing users.
142
+ 3. Actually close the object.
143
+
144
+ It's also possible to do them in a different order if that's more
145
+ convenient, *but only if* you make sure not to have any checkpoints in
146
+ between the steps. This way they all happen in a single atomic
147
+ step, so other tasks won't be able to tell what order they happened
148
+ in anyway.
149
+ """
150
+ try:
151
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.notify_closing(fd)
152
+ except AttributeError:
153
+ raise RuntimeError("must be called from async context") from None
@@ -0,0 +1,204 @@
1
+ # ***********************************************************
2
+ # ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST ******
3
+ # *************************************************************
4
+ from __future__ import annotations
5
+
6
+ import sys
7
+ from typing import TYPE_CHECKING
8
+
9
+ from ._ki import enable_ki_protection
10
+ from ._run import GLOBAL_RUN_CONTEXT
11
+
12
+ if TYPE_CHECKING:
13
+ from contextlib import AbstractContextManager
14
+
15
+ from typing_extensions import Buffer
16
+
17
+ from .._file_io import _HasFileNo
18
+ from ._unbounded_queue import UnboundedQueue
19
+ from ._windows_cffi import CData, Handle
20
+
21
+ assert not TYPE_CHECKING or sys.platform == "win32"
22
+
23
+
24
+ __all__ = [
25
+ "current_iocp",
26
+ "monitor_completion_key",
27
+ "notify_closing",
28
+ "readinto_overlapped",
29
+ "register_with_iocp",
30
+ "wait_overlapped",
31
+ "wait_readable",
32
+ "wait_writable",
33
+ "write_overlapped",
34
+ ]
35
+
36
+
37
+ @enable_ki_protection
38
+ async def wait_readable(sock: _HasFileNo | int) -> None:
39
+ """Block until the kernel reports that the given object is readable.
40
+
41
+ On Unix systems, ``sock`` must either be an integer file descriptor,
42
+ or else an object with a ``.fileno()`` method which returns an
43
+ integer file descriptor. Any kind of file descriptor can be passed,
44
+ though the exact semantics will depend on your kernel. For example,
45
+ this probably won't do anything useful for on-disk files.
46
+
47
+ On Windows systems, ``sock`` must either be an integer ``SOCKET``
48
+ handle, or else an object with a ``.fileno()`` method which returns
49
+ an integer ``SOCKET`` handle. File descriptors aren't supported,
50
+ and neither are handles that refer to anything besides a
51
+ ``SOCKET``.
52
+
53
+ :raises trio.BusyResourceError:
54
+ if another task is already waiting for the given socket to
55
+ become readable.
56
+ :raises trio.ClosedResourceError:
57
+ if another task calls :func:`notify_closing` while this
58
+ function is still working.
59
+ """
60
+ try:
61
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_readable(sock)
62
+ except AttributeError:
63
+ raise RuntimeError("must be called from async context") from None
64
+
65
+
66
+ @enable_ki_protection
67
+ async def wait_writable(sock: _HasFileNo | int) -> None:
68
+ """Block until the kernel reports that the given object is writable.
69
+
70
+ See `wait_readable` for the definition of ``sock``.
71
+
72
+ :raises trio.BusyResourceError:
73
+ if another task is already waiting for the given socket to
74
+ become writable.
75
+ :raises trio.ClosedResourceError:
76
+ if another task calls :func:`notify_closing` while this
77
+ function is still working.
78
+ """
79
+ try:
80
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_writable(sock)
81
+ except AttributeError:
82
+ raise RuntimeError("must be called from async context") from None
83
+
84
+
85
+ @enable_ki_protection
86
+ def notify_closing(handle: Handle | int | _HasFileNo) -> None:
87
+ """Notify waiters of the given object that it will be closed.
88
+
89
+ Call this before closing a file descriptor (on Unix) or socket (on
90
+ Windows). This will cause any `wait_readable` or `wait_writable`
91
+ calls on the given object to immediately wake up and raise
92
+ `~trio.ClosedResourceError`.
93
+
94
+ This doesn't actually close the object – you still have to do that
95
+ yourself afterwards. Also, you want to be careful to make sure no
96
+ new tasks start waiting on the object in between when you call this
97
+ and when it's actually closed. So to close something properly, you
98
+ usually want to do these steps in order:
99
+
100
+ 1. Explicitly mark the object as closed, so that any new attempts
101
+ to use it will abort before they start.
102
+ 2. Call `notify_closing` to wake up any already-existing users.
103
+ 3. Actually close the object.
104
+
105
+ It's also possible to do them in a different order if that's more
106
+ convenient, *but only if* you make sure not to have any checkpoints in
107
+ between the steps. This way they all happen in a single atomic
108
+ step, so other tasks won't be able to tell what order they happened
109
+ in anyway.
110
+ """
111
+ try:
112
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.notify_closing(handle)
113
+ except AttributeError:
114
+ raise RuntimeError("must be called from async context") from None
115
+
116
+
117
+ @enable_ki_protection
118
+ def register_with_iocp(handle: int | CData) -> None:
119
+ """TODO: these are implemented, but are currently more of a sketch than
120
+ anything real. See `#26
121
+ <https://github.com/python-trio/trio/issues/26>`__ and `#52
122
+ <https://github.com/python-trio/trio/issues/52>`__.
123
+ """
124
+ try:
125
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.register_with_iocp(handle)
126
+ except AttributeError:
127
+ raise RuntimeError("must be called from async context") from None
128
+
129
+
130
+ @enable_ki_protection
131
+ async def wait_overlapped(handle_: int | CData, lpOverlapped: CData | int) -> object:
132
+ """TODO: these are implemented, but are currently more of a sketch than
133
+ anything real. See `#26
134
+ <https://github.com/python-trio/trio/issues/26>`__ and `#52
135
+ <https://github.com/python-trio/trio/issues/52>`__.
136
+ """
137
+ try:
138
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.wait_overlapped(
139
+ handle_, lpOverlapped
140
+ )
141
+ except AttributeError:
142
+ raise RuntimeError("must be called from async context") from None
143
+
144
+
145
+ @enable_ki_protection
146
+ async def write_overlapped(
147
+ handle: int | CData, data: Buffer, file_offset: int = 0
148
+ ) -> int:
149
+ """TODO: these are implemented, but are currently more of a sketch than
150
+ anything real. See `#26
151
+ <https://github.com/python-trio/trio/issues/26>`__ and `#52
152
+ <https://github.com/python-trio/trio/issues/52>`__.
153
+ """
154
+ try:
155
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.write_overlapped(
156
+ handle, data, file_offset
157
+ )
158
+ except AttributeError:
159
+ raise RuntimeError("must be called from async context") from None
160
+
161
+
162
+ @enable_ki_protection
163
+ async def readinto_overlapped(
164
+ handle: int | CData, buffer: Buffer, file_offset: int = 0
165
+ ) -> int:
166
+ """TODO: these are implemented, but are currently more of a sketch than
167
+ anything real. See `#26
168
+ <https://github.com/python-trio/trio/issues/26>`__ and `#52
169
+ <https://github.com/python-trio/trio/issues/52>`__.
170
+ """
171
+ try:
172
+ return await GLOBAL_RUN_CONTEXT.runner.io_manager.readinto_overlapped(
173
+ handle, buffer, file_offset
174
+ )
175
+ except AttributeError:
176
+ raise RuntimeError("must be called from async context") from None
177
+
178
+
179
+ @enable_ki_protection
180
+ def current_iocp() -> int:
181
+ """TODO: these are implemented, but are currently more of a sketch than
182
+ anything real. See `#26
183
+ <https://github.com/python-trio/trio/issues/26>`__ and `#52
184
+ <https://github.com/python-trio/trio/issues/52>`__.
185
+ """
186
+ try:
187
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.current_iocp()
188
+ except AttributeError:
189
+ raise RuntimeError("must be called from async context") from None
190
+
191
+
192
+ @enable_ki_protection
193
+ def monitor_completion_key() -> (
194
+ AbstractContextManager[tuple[int, UnboundedQueue[object]]]
195
+ ):
196
+ """TODO: these are implemented, but are currently more of a sketch than
197
+ anything real. See `#26
198
+ <https://github.com/python-trio/trio/issues/26>`__ and `#52
199
+ <https://github.com/python-trio/trio/issues/52>`__.
200
+ """
201
+ try:
202
+ return GLOBAL_RUN_CONTEXT.runner.io_manager.monitor_completion_key()
203
+ except AttributeError:
204
+ raise RuntimeError("must be called from async context") from None