PyDocs

Nav

Networking and Interprocess Communication

Task

asyncio

classDeprecated 3.10not WASI
  • Task(coro, *, loop=None, name=None, context=None, eager_start=False)
Deprecated since 3.10. Deprecation warning is emitted if loop is not specified and there is no running event loop.
A coroutine wrapped in a Future.
Changed in 3.7, 3.8, 3.11, 3.12, 3.13
  • 3.7: Added support for the contextvars module.
  • 3.8: Added the name parameter.
  • 3.11: Added the context parameter.
  • 3.12: Added the eager_start parameter.
  • 3.13: Changed to rescind pending cancellation requests upon reaching zero.
Members of Task

_

__init__
Initialize self.

a

add_done_callback
Add a callback to be run when the future becomes done.

c

cancel
Request that this task cancel itself.
cancelled
Return True if the future was cancelled.
cancelling
Return the count of the task's cancellation requests.

d

done
Return True if the future is done.

e

exception
Return the exception that was set on this future.

g

get_context
Return the contextvars.Context object associated with the task.
get_coro
Return the coroutine object wrapped by the Task.
get_name
Return the name of the Task.
get_stack
Return the list of stack frames for this task's coroutine.

p

print_stack
Print the stack or traceback for this task's coroutine.

r

remove_done_callback
Remove all instances of a callback from the "call when done" list.
result
Return the result this future represents.

s

set_name
Set the name of the Task.

u

uncancel
Decrement the task's count of cancellation requests.
0 Examples
No examples for asyncio/Task.
See Also
No see-alsos for asyncio/Task
0 Notes
No notes for Task