Skip to content

Commit e88bc3c

Browse files
committed
fixing for issues with callback structure
1 parent d0b2dd3 commit e88bc3c

File tree

2 files changed

+9
-64
lines changed

2 files changed

+9
-64
lines changed

dash/_callback.py

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,8 @@ def _handle_rest_background_callback(
499499
response["sideUpdate"] = updated_props
500500
has_update = True
501501

502-
if output_value is callback_manager.UNDEFINED:
503-
return to_json(response), has_update, True
504-
else:
505-
try:
506-
output_value = _invoke_callback(func, *func_args, **func_kwargs) # type: ignore[reportArgumentType]
507-
except PreventUpdate as err:
508-
raise err
509-
except Exception as err: # pylint: disable=broad-exception-caught
510-
if error_handler:
511-
output_value = error_handler(err)
502+
if output_value is callback_manager.UNDEFINED:
503+
return to_json(response), has_update, True
512504
return output_value, has_update, False
513505

514506

@@ -588,58 +580,6 @@ def _prepare_response(
588580
response["dist"] = dist
589581
return response.update({"response": component_ids})
590582

591-
# pylint: disable=too-many-branches,too-many-statements
592-
def register_callback(
593-
callback_list, callback_map, config_prevent_initial_callbacks, *_args, **_kwargs
594-
):
595-
(
596-
output,
597-
flat_inputs,
598-
flat_state,
599-
inputs_state_indices,
600-
prevent_initial_call,
601-
) = handle_grouped_callback_args(_args, _kwargs)
602-
if isinstance(output, Output):
603-
# Insert callback with scalar (non-multi) Output
604-
insert_output = output
605-
multi = False
606-
has_output = True
607-
else:
608-
# Insert callback as multi Output
609-
insert_output = flatten_grouping(output)
610-
multi = True
611-
has_output = len(output) > 0
612-
613-
background = _kwargs.get("background")
614-
manager = _kwargs.get("manager")
615-
running = _kwargs.get("running")
616-
on_error = _kwargs.get("on_error")
617-
if running is not None:
618-
if not isinstance(running[0], (list, tuple)):
619-
running = [running]
620-
running = {
621-
"running": {str(r[0]): r[1] for r in running},
622-
"runningOff": {str(r[0]): r[2] for r in running},
623-
}
624-
allow_dynamic_callbacks = _kwargs.get("_allow_dynamic_callbacks")
625-
626-
output_indices = make_grouping_by_index(output, list(range(grouping_len(output))))
627-
callback_id = insert_callback(
628-
callback_list,
629-
callback_map,
630-
config_prevent_initial_callbacks,
631-
insert_output,
632-
output_indices,
633-
flat_inputs,
634-
flat_state,
635-
inputs_state_indices,
636-
prevent_initial_call,
637-
background=background,
638-
manager=manager,
639-
dynamic_creator=allow_dynamic_callbacks,
640-
running=running,
641-
no_output=not has_output,
642-
)
643583

644584
# pylint: disable=too-many-branches,too-many-statements
645585
def register_callback(
@@ -744,7 +684,13 @@ def add_context(*args, **kwargs):
744684
if skip:
745685
return output_value
746686
else:
747-
output_value = _invoke_callback(func, *func_args, **func_kwargs)
687+
try:
688+
output_value = _invoke_callback(func, *func_args, **func_kwargs) # type: ignore[reportArgumentType]
689+
except PreventUpdate as err:
690+
raise err
691+
except Exception as err: # pylint: disable=broad-exception-caught
692+
if error_handler:
693+
output_value = error_handler(err)
748694
except PreventUpdate:
749695
raise
750696
except Exception as err: # pylint: disable=broad-exception-caught

dash/dash.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2509,7 +2509,6 @@ def update(pathname_, search_, **states):
25092509
for page in _pages.PAGE_REGISTRY.values()
25102510
]
25112511
+ layout
2512-
25132512
)
25142513
if _ID_CONTENT not in self.validation_layout:
25152514
raise Exception("`dash.page_container` not found in the layout")

0 commit comments

Comments
 (0)