MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / __aenter__

Method __aenter__

src/telegram/_bot.py:404–420  ·  view source on GitHub ↗

|async_context_manager| :meth:`initializes ` the Bot. Returns: The initialized Bot instance. Raises: :exc:`Exception`: If an exception is raised during initialization, :meth:`shutdown` is called in this case.

(self: BT)

Source from the content-addressed store, hash-verified

402 self._freeze()
403
404 async def __aenter__(self: BT) -> BT:
405 """
406 |async_context_manager| :meth:`initializes <initialize>` the Bot.
407
408 Returns:
409 The initialized Bot instance.
410
411 Raises:
412 :exc:`Exception`: If an exception is raised during initialization, :meth:`shutdown`
413 is called in this case.
414 """
415 try:
416 await self.initialize()
417 except Exception:
418 await self.shutdown()
419 raise
420 return self
421
422 async def __aexit__(
423 self,

Callers

nothing calls this directly

Calls 2

initializeMethod · 0.95
shutdownMethod · 0.95

Tested by

no test coverage detected