You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] UnboundLocalError: user_callback_output in async background callbacks when callback raises an exception or PreventUpdate #3821
In async_run(), user_callback_output is only assigned inside the try block. When the callback raises, control jumps to the except block (which sets errored = True), then reaches:
Since user_callback_output was never assigned, this raises UnboundLocalError. The synchronous run() path does not have this bug because it initialises user_callback_output = None before the try.
Steps to reproduce
fromdashimportDash, Input, Output, html, callbackfromdash.exceptionsimportPreventUpdate# ... configure a CeleryManager or DiskcacheManager as background_callback_manager@callback(Output("out", "children"),Input("btn", "n_clicks"),background=True,prevent_initial_call=True,)asyncdefhandler(_):
raisePreventUpdate# or: raise Exception("boom")
Clicking the button raises UnboundLocalError in the worker instead of cleanly preventing the update / reporting the error.
Expected behaviour
An async background callback that raises PreventUpdate or an exception should behave like the synchronous case: the no-update result or background_callback_error is reported, and the original error is not masked.
Activity