`shutdown_waits_for` example doesn't work as intended
See original GitHub issueIn the readme the following example is given:
import asyncio
from aiorun import run, shutdown_waits_for
async def corofn():
await asyncio.sleep(60)
print('done!')
async def main():
try:
await shutdown_waits_for(corofn())
except asyncio.CancelledError
print('oh noes!')
run(main())
With the explanation:
If you hit CTRL-C before 60 seconds has passed, you will see oh noes! printed immediately, and then after 60 seconds (since start), done! is printed, and thereafter the program exits.
I’m finding that this isn’t the case. The program never actually exits on its own.
(Also there’s a missing :
on the end of the asyncio.CancelledError
)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Gunicorn 20.1.0 worker does not respect graceful timeout option
TERM: Graceful shutdown. Waits for workers to finish their current requests up to the graceful_timeout. Example code: (download django-mvp.zip).
Read more >Gunicorn Documentation - Read the Docs
When using a paste configuration be sure that the server block does not import any application code or the reload will not work...
Read more >sys.dm_os_wait_stats (Transact-SQL) - SQL Server
Occurs when a thread from the dispatcher pool is waiting for more work to process. The wait time for this wait type is...
Read more >Stop Logstash with a Filter or Ruby-Code - Elastic Discuss
Thanks for the response. Today I had the chance (finally) to test your approach, but unfortunately it doesn't work. Perhaps as expected. On...
Read more >Apache Accumulo® User Manual Version 1.8
Data will not be lost even if the entire cluster suddenly loses power. ... It is expected that the user launching the MapReduce...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep:
By simple stopping the loop, the graceful-shutdown procedures inside aiorun will take over, cancel all pending tasks etc.
If this resolves it, pls feel free to close the issue 👍🏼
Gotcha. Sorry, I misunderstood that part of the readme.
Is there a way I can “nicely” make a
aiorun.run()
process exit? While I’m testing my script using CTRL-C is excellent, but now that I’m looking to rig my python script up as a linux service I’m looking for a way to be able to trigger a halt in a nice way.