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

Method __init__

Lib/asyncio/tasks.py:84–113  ·  view source on GitHub ↗
(self, coro, *, loop=None, name=None, context=None,
                 eager_start=False)

Source from the content-addressed store, hash-verified

82 _log_destroy_pending = True
83
84 def __init__(self, coro, *, loop=None, name=None, context=None,
85 eager_start=False):
86 super().__init__(loop=loop)
87 if self._source_traceback:
88 del self._source_traceback[-1]
89 if not coroutines.iscoroutine(coro):
90 # raise after Future.__init__(), attrs are required for __del__
91 # prevent logging for pending task in __del__
92 self._log_destroy_pending = False
93 raise TypeError(f"a coroutine was expected, got {coro!r}")
94
95 if name is None:
96 self._name = f'Task-{_task_name_counter()}'
97 else:
98 self._name = str(name)
99
100 self._num_cancels_requested = 0
101 self._must_cancel = False
102 self._fut_waiter = None
103 self._coro = coro
104 if context is None:
105 self._context = contextvars.copy_context()
106 else:
107 self._context = context
108
109 if eager_start and self._loop.is_running():
110 self.__eager_start()
111 else:
112 self._loop.call_soon(self.__step, context=self._context)
113 _py_register_task(self)
114
115 def __del__(self):
116 if self._state == futures._PENDING and self._log_destroy_pending:

Callers 1

__init__Method · 0.45

Calls 5

__eager_startMethod · 0.95
superClass · 0.85
strFunction · 0.85
is_runningMethod · 0.45
call_soonMethod · 0.45

Tested by

no test coverage detected