@@ -186,19 +186,24 @@ Running and stopping the loop
186
186
.. coroutinemethod :: loop.shutdown_default_executor(timeout=None)
187
187
188
188
Schedule the closure of the default executor and wait for it to join all of
189
- the threads in the :class: `ThreadPoolExecutor `. After calling this method, a
190
- :exc: `RuntimeError ` will be raised if :meth: `loop.run_in_executor ` is called
191
- while using the default executor.
189
+ the threads in the :class: `~concurrent.futures.ThreadPoolExecutor `.
190
+ Once this method has been called,
191
+ using the default executor with :meth: `loop.run_in_executor `
192
+ will raise a :exc: `RuntimeError `.
192
193
193
- The *timeout * parameter specifies the amount of time the executor will
194
- be given to finish joining. The default value is ``None ``, which means the
195
- executor will be given an unlimited amount of time.
194
+ The *timeout * parameter specifies the amount of time
195
+ (in :class: `float ` seconds) the executor will be given to finish joining.
196
+ With the default, ``None ``,
197
+ the executor is allowed an unlimited amount of time.
196
198
197
- If the timeout duration is reached, a warning is emitted and executor is
198
- terminated without waiting for its threads to finish joining.
199
+ If the *timeout * is reached, a :exc: `RuntimeWarning ` is emitted
200
+ and the default executor is terminated
201
+ without waiting for its threads to finish joining.
199
202
200
- Note that there is no need to call this function when
201
- :func: `asyncio.run ` is used.
203
+ .. note ::
204
+
205
+ Do not call this method when using :func: `asyncio.run `,
206
+ as the latter handles default executor shutdown automatically.
202
207
203
208
.. versionadded :: 3.9
204
209
@@ -213,22 +218,23 @@ Scheduling callbacks
213
218
Schedule the *callback * :term: `callback ` to be called with
214
219
*args * arguments at the next iteration of the event loop.
215
220
221
+ Return an instance of :class: `asyncio.Handle `,
222
+ which can be used later to cancel the callback.
223
+
216
224
Callbacks are called in the order in which they are registered.
217
225
Each callback will be called exactly once.
218
226
219
- An optional keyword-only *context * argument allows specifying a
227
+ The optional keyword-only *context * argument specifies a
220
228
custom :class: `contextvars.Context ` for the *callback * to run in.
221
- The current context is used when no *context * is provided.
222
-
223
A611
- An instance of :class: `asyncio.Handle ` is returned, which can be
224
- used later to cancel the callback.
229
+ Callbacks use the current context when no *context * is provided.
225
230
226
- This method is not thread-safe.
231
+ Unlike :meth: ` call_soon_threadsafe `, this method is not thread-safe.
227
232
228
233
.. method :: loop.call_soon_threadsafe(callback, *args, context=None)
229
234
230
- A thread-safe variant of :meth: `call_soon `. Must be used to
231
- schedule callbacks *from another thread *.
235
+ A thread-safe variant of :meth: `call_soon `. When scheduling callbacks from
236
+ another thread, this function *must * be used, since :meth: `call_soon ` is not
237
+ thread-safe.
232
238
233
239
Raises :exc: `RuntimeError ` if called on a loop that's been closed.
234
240
This can happen on a secondary thread when the main application is
0 commit comments