MCPcopy Index your code
hub / github.com/python/cpython / create_task

Method create_task

Lib/asyncio/base_events.py:465–482  ·  view source on GitHub ↗

Schedule or begin executing a coroutine object. Return a task object.

(self, coro, **kwargs)

Source from the content-addressed store, hash-verified

463 return futures.Future(loop=self)
464
465 def create_task(self, coro, **kwargs):
466 """Schedule or begin executing a coroutine object.
467
468 Return a task object.
469 """
470 self._check_closed()
471 if self._task_factory is not None:
472 return self._task_factory(self, coro, **kwargs)
473
474 task = tasks.Task(coro, loop=self, **kwargs)
475 if task._source_traceback:
476 del task._source_traceback[-1]
477 try:
478 return task
479 finally:
480 # gh-128552: prevent a refcycle of
481 # task.exception().__traceback__->BaseEventLoop.create_task->task
482 del task
483
484 def set_task_factory(self, factory):
485 """Set a task factory that will be used by loop.create_task().

Callers

nothing calls this directly

Calls 1

_check_closedMethod · 0.95

Tested by

no test coverage detected