• Home
  • Raw
  • Download

Lines Matching full:task

81   concurrently as asyncio :class:`Tasks <Task>`.
183 When a coroutine is wrapped into a *Task* with functions like
195 task = asyncio.create_task(nested())
197 # "task" can now be used to cancel "nested()", or
199 await task
243 Wrap the *coro* :ref:`coroutine <coroutine>` into a :class:`Task`
244 and schedule its execution. Return the Task object.
246 If *name* is not ``None``, it is set as the name of the task using
247 :meth:`Task.set_name`.
253 The task is executed in the loop returned by :func:`get_running_loop`,
265 a task disappearing mid-execution. The event loop only keeps
266 weak references to tasks. A task that isn't referenced elsewhere
274 task = asyncio.create_task(some_coro(param=i))
276 # Add task to the set. This creates a strong reference.
277 background_tasks.add(task)
280 # make each task remove its own reference from the set after
282 task.add_done_callback(background_tasks.discard)
293 Task Cancellation
297 When a task is cancelled, :exc:`asyncio.CancelledError` will be raised
298 in the task at the next opportunity.
310 should not generally call :meth:`uncancel <asyncio.Task.uncancel>`.
317 Task Groups
320 Task groups combine a task creation API with a convenient
334 Create a task in this task group.
349 Once the last task has finished and the ``async with`` block is exited,
358 the task directly containing the ``async with`` statement is also cancelled.
370 If any task fails with :exc:`KeyboardInterrupt` or :exc:`SystemExit`,
371 the task group still cancels the remaining tasks and waits for them,
398 ``sleep()`` always suspends the current task, allowing other tasks
438 scheduled as a Task.
445 raised exception is immediately propagated to the task that
455 If any Task or Future from the *aws* sequence is *cancelled*, it is
458 cancellation of one submitted Task/Future to cause other
474 print(f"Task {name}: Compute factorial({number}), currently i={i}...")
477 print(f"Task {name}: factorial({number}) = {f}")
493 # Task A: Compute factorial(2), currently i=2...
494 # Task B: Compute factorial(3), currently i=2...
495 # Task C: Compute factorial(4), currently i=2...
496 # Task A: factorial(2) = 2
497 # Task B: Compute factorial(3), currently i=3...
498 # Task C: Compute factorial(4), currently i=3...
499 # Task B: factorial(3) = 6
500 # Task C: Compute factorial(4), currently i=4...
501 # Task C: factorial(4) = 24
531 from being :meth:`cancelled <Task.cancel>`.
533 If *aw* is a coroutine it is automatically scheduled as a Task.
537 task = asyncio.create_task(something())
538 res = await shield(task)
545 Task running in ``something()`` is not cancelled. From the point
557 task = asyncio.create_task(something())
559 res = await shield(task)
566 a task disappearing mid-execution. The event loop only keeps
567 weak references to tasks. A task that isn't referenced elsewhere
602 the context manager will cancel the current task and handle
699 If *aw* is a coroutine it is automatically scheduled as a Task.
705 If a timeout occurs, it cancels the task and raises
708 To avoid the task :meth:`cancellation <Task.cancel>`,
756 Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the *aws*
912 will be notified. It can also be used to cancel the task in
918 print('The coroutine took too long, cancelling the task...')
940 Return the currently running :class:`Task` instance, or ``None`` if
941 no task is running.
951 Return a set of not yet finished :class:`Task` objects run by
967 Task Object
970 .. class:: Task(coro, *, loop=None, name=None, context=None)
976 If a coroutine awaits on a Future, the Task suspends
982 one Task at a time. While a Task awaits for the completion of a
991 To cancel a running Task use the :meth:`cancel` method. Calling it
992 will cause the Task to throw a :exc:`CancelledError` exception into
996 :meth:`cancelled` can be used to check if the Task was cancelled.
1001 :class:`asyncio.Task` inherits from :class:`Future` all of its
1007 If no *context* is provided, the Task copies the current context
1025 Return ``True`` if the Task is *done*.
1027 A Task is *done* when the wrapped coroutine either returned
1028 a value, raised an exception, or the Task was cancelled.
1032 Return the result of the Task.
1034 If the Task is *done*, the result of the wrapped coroutine
1038 If the Task has been *cancelled*, this method raises
1041 If the Task's result isn't yet available, this method raises
1046 Return the exception of the Task.
1052 If the Task has been *cancelled*, this method raises a
1055 If the Task isn't *done* yet, this method raises an
1060 Add a callback to be run when the Task is *done*.
1078 Return the list of stack frames for this Task.
1099 Print the stack or traceback for this Task.
1111 Return the coroutine object wrapped by the :class:`Task`.
1117 Return the name of the Task.
1119 If no name has been explicitly assigned to the Task, the default
1120 asyncio Task implementation generates a default name during
1127 Set the name of the Task.
1132 In the default Task implementation, the name will be visible
1133 in the :func:`repr` output of a task object.
1139 Request the Task to be cancelled.
1147 Therefore, unlike :meth:`Future.cancel`, :meth:`Task.cancel` does
1148 not guarantee that the Task will be cancelled, although
1151 the cancellation, it needs to call :meth:`Task.uncancel` in addition
1158 The ``msg`` parameter is propagated from cancelled task to its awaiter.
1178 # Create a "cancel_me" Task
1179 task = asyncio.create_task(cancel_me())
1184 task.cancel()
1186 await task
1201 Return ``True`` if the Task is *cancelled*.
1203 The Task is *cancelled* when the cancellation was requested with
1209 Decrement the count of cancellation requests to this Task.
1213 Note that once execution of a cancelled task completed, further
1219 used by end-user code. In particular, if a Task gets successfully
1248 Return the number of pending cancellation requests to this Task, i.e.,
1252 Note that if this number is greater than zero but the Task is
1255 which can lead to the task not being cancelled after all if the