question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Polling doesn't stop on receiving SIGTERM in Docker

See original GitHub issue

I have been using docker for a while and I have noticed 10 second delay before stopping the container. Now I realized that it is because aiogram doesn’t shutdown when SIGTERM signal was sent. When do docker kill --signal SIGINT, everything looks normal now.

Is it possible to make aiogram to shutdown on SIGTERM as well?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
drdilyorcommented, Jun 25, 2021

@kamikazebr yes, I have already deleted the bot after 2days

2reactions
RSBatcommented, Apr 27, 2022

Solved the problem by setting handlers myself

 bot = Bot(token=bot_token)
 storage = RedisStorage2(host=redis_host)
 dp = Dispatcher(bot, storage=storage)

 asyncio.get_event_loop().add_signal_handler(signal.SIGTERM, dp.stop_polling)
 asyncio.get_event_loop().add_signal_handler(signal.SIGINT, dp.stop_polling)

 await dp.start_polling()

 await storage.close()
 await bot.close()
 await dp.wait_closed()
 await storage.wait_closed()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Polling doesn't stop on receiving SIGTERM in Docker -
Polling doesn't stop on receiving SIGTERM in Docker. ... Now I realized that it is because aiogram doesn't shutdown when SIGTERM signal was...
Read more >
Best practices for propagating signals on Docker - Kaggle
When Docker recieves SIGTERM , it forwards the signal to the container and then exits immediately. It does not wait for the container...
Read more >
master process running in container doesn't get SIGTERM on ...
As this issue says, it seems like the process running inside the container isn't getting the SIGTERM sent by Docker. I have the...
Read more >
child_process didn't receive SIGTERM inside docker container
I try to kill application three different way and none of them works. Application didn't receive SIGTERM no before exit and after manually ......
Read more >
Why Your Dockerized Application Isn't Receiving Signals
So if you've ever wondered why your docker stop takes so long – this might be the reason: you didn't listen for SIGTERM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found