Skip to content

Task was destroyed but it is pending #927

Closed
@koval01

Description

@koval01

Context

I'm using aiogram to design my bot into telegrams, but as the load increased, I started getting a weird bug.

  • Operating System: Linux (Heroku-22)
  • Python Version: 3.9.13
  • aiogram version: 2.20
  • aiohttp version: 3.8.1
  • uvloop version (if installed): 0.16.0

Expected Behavior

I expect there was no such mistake.

Current Behavior

In parallel with receiving this error, the bot ignores requests.

Failure Information (for bugs)

Task was destroyed but it is pending!
task: <Task pending name='Task-88390' coro=<Dispatcher._process_polling_updates() done, defined at /app/.heroku/python/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py:407> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0x7fb1052d0ac0>()]>>

Steps to Reproduce

The work of the bot under load

Failure Logs

2022-06-18T22:30:32.381817+00:00 app[worker.1]: aiogram.contrib.middlewares.logging - INFO - Process update [ID:844341375]: [failed] (in 607 ms)
2022-06-18T22:30:32.381955+00:00 app[worker.1]: Exception ignored in: <coroutine object Dispatcher.process_update at 0x7fb103ee80c0>
2022-06-18T22:30:32.381968+00:00 app[worker.1]: Traceback (most recent call last):
2022-06-18T22:30:32.381973+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
2022-06-18T22:30:32.382784+00:00 app[worker.1]:     return await self.message_handlers.notify(update.message)
2022-06-18T22:30:32.382785+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 126, in notify
2022-06-18T22:30:32.382785+00:00 app[worker.1]:     current_handler.reset(ctx_token)
2022-06-18T22:30:32.382786+00:00 app[worker.1]: ValueError: <Token var=<ContextVar name='current_handler' at 0x7fb10a5aba90> at 0x7fb103e5d9c0> was created in a different Context
2022-06-18T22:30:32.382787+00:00 app[worker.1]: Exception ignored in: <coroutine object Handler.notify at 0x7fb103ee8040>
2022-06-18T22:30:32.382787+00:00 app[worker.1]: Traceback (most recent call last):
2022-06-18T22:30:32.382787+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 126, in notify
2022-06-18T22:30:32.382788+00:00 app[worker.1]:     current_handler.reset(ctx_token)
2022-06-18T22:30:32.382788+00:00 app[worker.1]: ValueError: <Token var=<ContextVar name='current_handler' at 0x7fb10a5aba90> at 0x7fb103e5d740> was created in a different Context
2022-06-18T22:30:32.382789+00:00 app[worker.1]: asyncio - ERROR - Task was destroyed but it is pending!
2022-06-18T22:30:32.382791+00:00 app[worker.1]: task: <Task pending name='Task-86501' coro=<Dispatcher._process_polling_updates() running at /app/.heroku/python/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py:415> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0x7fb0fedbe5b0>()]>>
2022-06-18T22:30:32.392733+00:00 app[worker.1]: aiologger - ERROR - Error write data to Redis in timer. Details: coroutine ignored GeneratorExit
2022-06-18T22:30:32.392784+00:00 app[worker.1]: aiologger - ERROR - Error send content (selector). Details: coroutine ignored GeneratorExit

Metadata

Metadata

Assignees

Labels

2.xIssue or PR for legacy 2.x versionneeds triageThis issue is not yet confirmed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions