-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThreadPoolExecutor loses exceptions. #120508
Comments
This is an expected behavior. They are not swallowed. They are saved and available to you if you call Changing this is a breaking change. Logging every raised exception will break programs which correctly handle them. |
I suggest to log only raised exceptions, which are not handled at all. I guess it means that failed future (or task) not |
This would be devastating too. You can stop at the first error and do not check other futures. Ignoring some exceptions can be normal behavior, for example when you you finish the work by closing a file and leaving tasks to die silently from OSError. Write a simple wrapper:
and wrap every function passed to |
Sure, I will use the idea, you express in the previous msg. But I cannot still accept internally the design. I assume it will take a little bit more time.🙂 Here is much more detailed: |
Bug report
Bug description:
This code just loses an exception. Without any notification.
The reason is in ThreadPoolExecutor's exceptions swallowing.
Proposals are:
The problem maybe seems too exaggerated, but if you have a some year old project with a bunch of places like this, it would mean probably you have a lot of hidden errors and need to analize all the code and fix with
try ... except
inside task or callingresult()
for every single future, which you got as a returned value ofThreadPoolExecutor.submit
. It sounds old old fashioned and smells like a bad design.By the way, if we could at least catch all these kind of unhandled exceptions, it would be a good solution.
Unfortunatly, neither
sys.excepthook
northreading.excepthook
catch anything interesting.All the same is valid for
ProcessPoolExecuter
as wellCPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: