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

Method __aexit__

Lib/asyncio/timeouts.py:95–123  ·  view source on GitHub ↗
(
        self,
        exc_type: type[BaseException] | None,
        exc_val: BaseException | None,
        exc_tb: TracebackType | None,
    )

Source from the content-addressed store, hash-verified

93 return self
94
95 async def __aexit__(
96 self,
97 exc_type: type[BaseException] | None,
98 exc_val: BaseException | None,
99 exc_tb: TracebackType | None,
100 ) -> bool | None:
101 assert self._state in (_State.ENTERED, _State.EXPIRING)
102
103 if self._timeout_handler is not None:
104 self._timeout_handler.cancel()
105 self._timeout_handler = None
106
107 if self._state is _State.EXPIRING:
108 self._state = _State.EXPIRED
109
110 if self._task.uncancel() <= self._cancelling and exc_type is not None:
111 # Since there are no new cancel requests, we're
112 # handling this.
113 if issubclass(exc_type, exceptions.CancelledError):
114 raise TimeoutError from exc_val
115 elif exc_val is not None:
116 self._insert_timeout_error(exc_val)
117 if isinstance(exc_val, ExceptionGroup):
118 for exc in exc_val.exceptions:
119 self._insert_timeout_error(exc)
120 elif self._state is _State.ENTERED:
121 self._state = _State.EXITED
122
123 return None
124
125 def _on_timeout(self) -> None:
126 assert self._state is _State.ENTERED

Callers

nothing calls this directly

Calls 3

_insert_timeout_errorMethod · 0.95
uncancelMethod · 0.80
cancelMethod · 0.45

Tested by

no test coverage detected