Message385589
> I'm dealing with a subtle deadlock involving concurrent.futures.ThreadPoolExecutor, and my solution that worked in Python 3.8 broke with 3.9. I'm running some long-running (possibly infinite) tasks in the thread pool, and I cancel them in an `atexit` callback so that everything can shut down cleanly (before ThreadPoolExecutor joins all worker threads in its own `atexit` hook).
IMO, a better practice would be providing those potentially infinite running tasks a direct method of escape and invoking it before calling executor.shutdown(), it would be a more reliable approach. But, perhaps there is some convenience utility in being able to provide custom atexit hooks. It also might help the user to separate the shutdown logic from the rest of the program.
Since you worked with me in adding threading._register_atexit(), Do you have any thoughts, Antoine? I would personally not be opposed to it being made public assuming there's real utility present in doing so.
My only concern is that it might be a potential foot-gun. If the user submits an atexit hook that deadlocks, it might prevent threads from shutting down safely prior to interpreter finalization. I'm presently undecided if explicitly mentioning that it in the docs would be sufficient warning. |
|
Date |
User |
Action |
Args |
2021-01-24 19:30:22 | aeros | set | recipients:
+ aeros, pitrou, vstinner, Ben.Darnell |
2021-01-24 19:30:22 | aeros | set | messageid: <1611516622.76.0.611691817616.issue41962@roundup.psfhosted.org> |
2021-01-24 19:30:22 | aeros | link | issue41962 messages |
2021-01-24 19:30:22 | aeros | create | |
|