MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __step

Method __step

tools/python-3.11.9-amd64/Lib/asyncio/tasks.py:260–345  ·  view source on GitHub ↗
(self, exc=None)

Source from the content-addressed store, hash-verified

258 return self._num_cancels_requested
259
260 def __step(self, exc=None):
261 if self.done():
262 raise exceptions.InvalidStateError(
263 f'_step(): already done: {self!r}, {exc!r}')
264 if self._must_cancel:
265 if not isinstance(exc, exceptions.CancelledError):
266 exc = self._make_cancelled_error()
267 self._must_cancel = False
268 coro = self._coro
269 self._fut_waiter = None
270
271 _enter_task(self._loop, self)
272 # Call either coro.throw(exc) or coro.send(None).
273 try:
274 if exc is None:
275 # We use the `send` method directly, because coroutines
276 # don't have `__iter__` and `__next__` methods.
277 result = coro.send(None)
278 else:
279 result = coro.throw(exc)
280 except StopIteration as exc:
281 if self._must_cancel:
282 # Task is cancelled right before coro stops.
283 self._must_cancel = False
284 super().cancel(msg=self._cancel_message)
285 else:
286 super().set_result(exc.value)
287 except exceptions.CancelledError as exc:
288 # Save the original exception so we can chain it later.
289 self._cancelled_exc = exc
290 super().cancel() # I.e., Future.cancel(self).
291 except (KeyboardInterrupt, SystemExit) as exc:
292 super().set_exception(exc)
293 raise
294 except BaseException as exc:
295 super().set_exception(exc)
296 else:
297 blocking = getattr(result, '_asyncio_future_blocking', None)
298 if blocking is not None:
299 # Yielded Future must come from Future.__iter__().
300 if futures._get_loop(result) is not self._loop:
301 new_exc = RuntimeError(
302 f'Task {self!r} got Future '
303 f'{result!r} attached to a different loop')
304 self._loop.call_soon(
305 self.__step, new_exc, context=self._context)
306 elif blocking:
307 if result is self:
308 new_exc = RuntimeError(
309 f'Task cannot await on itself: {self!r}')
310 self._loop.call_soon(
311 self.__step, new_exc, context=self._context)
312 else:
313 result._asyncio_future_blocking = False
314 result.add_done_callback(
315 self.__wakeup, context=self._context)
316 self._fut_waiter = result
317 if self._must_cancel:

Callers 1

__wakeupMethod · 0.95

Calls 12

_enter_taskFunction · 0.85
_leave_taskFunction · 0.85
_make_cancelled_errorMethod · 0.80
_get_loopMethod · 0.80
doneMethod · 0.45
sendMethod · 0.45
throwMethod · 0.45
cancelMethod · 0.45
set_resultMethod · 0.45
set_exceptionMethod · 0.45
call_soonMethod · 0.45
add_done_callbackMethod · 0.45

Tested by

no test coverage detected