-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Rethink exception handling #318
Comments
"error" seems like the least worst choice. (Thanks @jwiggins for the suggestion.) |
We should also look at what
|
Removing the 0.3.0 milestone; there's no particular urgency on this. |
Was about to open a similar issue, so just want to give this a +1... having the exception object is convenient for passing through to |
Thanks @mdsmarte; the Just to be clear, for now I'd recommend that background tasks don't deliberately make use of exceptions for communication with the future; "expected" failures should be communicated in the return value, instead (which may mean adding a big |
Here's the Script: import concurrent.futures
import logging
logger = logging.getLogger(__name__)
def f(): g()
def g(): h()
def h(): 1/0
if __name__ == "__main__":
try:
with concurrent.futures.ProcessPoolExecutor() as executor:
executor.submit(f).result()
except Exception:
logger.exception("something went wrong") Results of executing this on my machine:
|
Currently, when an exception is raised by a background task, the future receives marshalled information related to that exception in its "exception" trait. The marshalled form of the exception isn't particularly standard, and isn't easy to use either.
Instead, we should consider simply providing the exception object. There's no need for the (type, value, traceback) triple: the exception object alone is enough - the traceback is already attached to the exception (since Python 3), and we can extract its type.
That would then allow a method call that either returns the result or raises the exception.
Things to worry about:
The text was updated successfully, but these errors were encountered: