-
Notifications
You must be signed in to change notification settings - Fork 220
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
errors from background tasks are not printed #78
Comments
we need to add logging. |
The exception is happening in separate thread that is the reason it is not printed. @kennethreitz What do you think will be the best approach to handle exception in futures? It is possible to have a custom ThreadPoolExecutor as it is proposed here. |
@kennethreitz What about passing callback functions to def on_success(result):
print(result)
def on_error(error):
print(error)
@api.background.task(on_success, on_error)
def sleep(s=10):
# Do background tasks here |
Although neat, this is dangerously close the Deferred structures used in Twisted. We use async and await to avoid that callback mess. I say ensuring exception are printed should be enough. Leaving the error handling up to the user is a lot more readable. Creating a separate decorator for this kind of error handling should be trivial should the user want it. |
I feel if you want something more sussinct, you should just use async/await |
Given:
When running
sleep
NameError
is thrown but no output is shown in console.The text was updated successfully, but these errors were encountered: