You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checkpoints are ``await``, ``async for``, and ``async with`` (on at least one of enter/exit). TODO write more and link stuff
101
+
Checkpoints are points where the async backend checks for cancellation and invokes scheduling checks. Possible checkpoints are ``await``, ``async for`` (before each iteration, and when exhausting the iterator), and ``async with`` (on at least one of enter/exit).
102
+
103
+
Trio has extensive and detailed documentation on the concept of :external+trio:ref:`checkpoints <checkpoints>`, and guarantees that all trio async functions will checkpoint (unless they raised an exception).
104
+
105
+
anyio does not currently have any documentation on checkpoints.
106
+
107
+
asyncio will checkpoint... ???
108
+
109
+
To make it easier to reason about checkpoints the :ref:`ASYNC91x <ASYNC910>` rules enforces the same rules as trio for your own project - i.e. all async functions must guarantee a checkpoint (or exception). To make it possible to reason the rules will also assume that all other async functions also adhere to those rules. This means you must be careful if you're using 3rd-party async libraries.
Async function definition with a ``timeout`` parameter.
41
41
In structured concurrency the caller should instead use :ref:`timeout context managers <timeout_context>`.
42
42
43
-
ASYNC110 : busy-wait
43
+
ASYNC110 : async-busy-wait
44
44
``while ...: await [trio/anyio].sleep()`` should be replaced by a :class:`trio.Event`/:class:`anyio.Event`.
45
45
46
46
ASYNC111 : variable-from-cm-in-start-soon
@@ -57,7 +57,7 @@ ASYNC113 : start-soon-in-aenter
57
57
ASYNC114 : startable-not-in-config
58
58
Startable function (i.e. has a ``task_status`` keyword parameter) not in :ref:`--startable-in-context-manager <--startable-in-context-manager>` parameter list, please add it so ASYNC113 can catch errors when using it.
59
59
60
-
ASYNC115 : sleep-zero
60
+
ASYNC115 : async-zero-sleep
61
61
Replace :func:`trio.sleep(0) <trio.sleep>`/:func:`anyio.sleep(0) <anyio.sleep>` with the more suggestive :func:`trio.lowlevel.checkpoint`/:func:`anyio.lowlevel.checkpoint`.
62
62
63
63
ASYNC116 : long-sleep-not-forever
@@ -78,44 +78,44 @@ Blocking sync calls in async functions
Note: 22X, 23X and 24X has not had asyncio-specific suggestions written.
81
+
.. _aiofiles: https://pypi.org/project/aiofiles/
82
+
.. _anyio: https://github.com/agronholm/anyio
83
83
84
84
ASYNC200 : blocking-configured-call
85
85
User-configured error for blocking sync calls in async functions.
86
86
Does nothing by default, see :ref:`async200-blocking-calls` for how to configure it.
87
87
88
88
ASYNC210 : blocking-http-call
89
89
Sync HTTP call in async function, use `httpx.AsyncClient`_.
90
-
This and the other ASYNC21x checks look for usage of `urllib3`_ and `httpx.Client`_, and recommend using `httpx.AsyncClient`_ as that's the largest http client supporting anyio/trio.
90
+
This and the other :ref:`ASYNC21x<ASYNC211>` checks look for usage of `urllib3`_ and `httpx.Client`_, and recommend using `httpx.AsyncClient`_ as that's the largest http client supporting anyio/trio.
91
91
92
-
ASYNC211 : blocking-http-call-pool
92
+
_`ASYNC211` : blocking-http-call-pool
93
93
Likely sync HTTP call in async function, use `httpx.AsyncClient`_.
94
94
Looks for `urllib3`_ method calls on pool objects, but only matching on the method signature and not the object.
95
95
96
96
ASYNC212 : blocking-http-call-httpx
97
97
Blocking sync HTTP call on httpx object, use `httpx.AsyncClient`_.
98
98
99
99
ASYNC220 : blocking-create-subprocess
100
-
Sync call to :class:`subprocess.Popen` (or equivalent) in async function, use :func:`trio.run_process`/:func:`anyio.run_process` in a :ref:`taskgroup_nursery`. ``asyncio`` users can use `asyncio.create_subprocess_[exec/shell] <https://docs.python.org/3/library/asyncio-subprocess.html>`_.
100
+
Sync call to :class:`subprocess.Popen` (or equivalent) in async function, use :func:`trio.run_process`/:func:`anyio.run_process`/:ref:`asyncio.create_subprocess_[exec/shell] <asyncio-subprocess>` in a :ref:`taskgroup_nursery`.
101
101
102
102
ASYNC221 : blocking-run-process
103
-
Sync call to :func:`subprocess.run` (or equivalent) in async function, use :func:`trio.run_process`/:func:`anyio.run_process`. ``asyncio`` users can use `asyncio.create_subprocess_[exec/shell] <https://docs.python.org/3/library/asyncio-subprocess.html>`_.
103
+
Sync call to :func:`subprocess.run` (or equivalent) in async function, use :func:`trio.run_process`/:func:`anyio.run_process`/:ref:`asyncio.create_subprocess_[exec/shell] <asyncio-subprocess>`.
104
104
105
105
ASYNC222 : blocking-process-wait
106
-
Sync call to :func:`os.wait` (or equivalent) in async function, wrap in :func:`trio.to_thread.run_sync`/:func:`anyio.to_thread.run_sync`. ``asyncio`` users can use `asyncio.loop.run_in_executor<https://docs.python.org/3/library/asyncio-subprocess.html>`_.
106
+
Sync call to :func:`os.wait` (or equivalent) in async function, wrap in :func:`trio.to_thread.run_sync`/:func:`anyio.to_thread.run_sync`/:meth:`asyncio.loop.run_in_executor`.
107
107
108
108
ASYNC230 : blocking-open-call
109
-
Sync call to :func:`open` in async function, use :func:`trio.open_file`/:func:`anyio.open_file`. ``asyncio`` users need to use a library such as `aiofiles<https://pypi.org/project/aiofiles/>`_, or switch to `anyio<https://github.com/agronholm/anyio>`_.
109
+
Sync call to :func:`open` in async function, use :func:`trio.open_file`/:func:`anyio.open_file`. ``asyncio`` users need to use a library such as `aiofiles`_, or switch to `anyio`_.
110
110
111
111
ASYNC231 : blocking-fdopen-call
112
-
Sync call to :func:`os.fdopen` in async function, use :func:`trio.wrap_file`/:func:`anyio.wrap_file`. ``asyncio`` users need to use a library such as `aiofiles<https://pypi.org/project/aiofiles/>`_, or switch to `anyio<https://github.com/agronholm/anyio>`_.
112
+
Sync call to :func:`os.fdopen` in async function, use :func:`trio.wrap_file`/:func:`anyio.wrap_file`. ``asyncio`` users need to use a library such as `aiofiles`_, or switch to `anyio`_.
113
113
114
114
ASYNC232 : blocking-file-call
115
115
Blocking sync call on file object, wrap the file object in :func:`trio.wrap_file`/:func:`anyio.wrap_file` to get an async file object.
116
116
117
117
ASYNC240 : blocking-path-usage
118
-
Avoid using :mod:`os.path` in async functions, prefer using :class:`trio.Path`/:class:`anyio.Path` objects. ``asyncio`` users should consider `aiopath <https://pypi.org/project/aiopath>`__ or `anyio<https://github.com/agronholm/anyio>`__.
118
+
Avoid using :mod:`os.path` in async functions, prefer using :class:`trio.Path`/:class:`anyio.Path` objects. ``asyncio`` users should consider `aiopath <https://pypi.org/project/aiopath>`__ or `anyio`_.
119
119
120
120
ASYNC250 : blocking-input
121
121
Builtin :func:`input` should not be called from async function.
0 commit comments