diff --git a/aiogram/utils/context.py b/aiogram/utils/context.py index 70c27b5b..2a846b23 100644 --- a/aiogram/utils/context.py +++ b/aiogram/utils/context.py @@ -21,7 +21,8 @@ def task_factory(loop: asyncio.BaseEventLoop, coro: typing.Coroutine): :rtype: :obj:`asyncio.Task` """ # Is not allowed when loop is closed. - loop._check_closed() + if loop.is_closed(): + raise RuntimeError('Event loop is closed.') task = asyncio.Task(coro, loop=loop)