Closed kevin-ip closed 1 year ago
I believe the issue here is that the thread loop is not properly shutdown. If you look at asyncio.run there are several steps to properly closing a loop. Unfortunately, the shutdown steps are not available in a convenient standalone method. It's a bit more re-usable in 3.11 though.
Another option would be to ensure _wakeup_timer_in_thread
is awaited on shutdown to give it a chance to get scheduled.
Give #39 a look, should fix the issue you see.
Checklist
master
branch of Mode.Steps to reproduce
I have a scheduled job that start and stop a ServiceThread but it complains "Task was destroyed but it is pending!" The following script simulates the scheduled job.
Expected behavior
The script should only print "hello"
Actual behavior
It complains "Task was destroyed but it is pending!"
Full traceback
Versions