Skip to content

Commit b5c1287

Browse files
committed
Fix cancel with manager from parameter.
1 parent d13a917 commit b5c1287

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

dash/_callback.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def callback(
183183
*_args,
184184
**_kwargs,
185185
long=long_spec,
186+
manager=manager,
186187
)
187188

188189

@@ -220,6 +221,7 @@ def insert_callback(
220221
inputs_state_indices,
221222
prevent_initial_call,
222223
long=None,
224+
manager=None,
223225
):
224226
if prevent_initial_call is None:
225227
prevent_initial_call = config_prevent_initial_callbacks
@@ -251,6 +253,7 @@ def insert_callback(
251253
"long": long,
252254
"output": output,
253255
"raw_inputs": inputs,
256+
"manager": manager,
254257
}
255258
callback_list.append(callback_spec)
256259

@@ -278,6 +281,7 @@ def register_callback( # pylint: disable=R0914
278281
multi = True
279282

280283
long = _kwargs.get("long")
284+
manager = _kwargs.get("manager")
281285

282286
output_indices = make_grouping_by_index(output, list(range(grouping_len(output))))
283287
callback_id = insert_callback(
@@ -291,6 +295,7 @@ def register_callback( # pylint: disable=R0914
291295
inputs_state_indices,
292296
prevent_initial_call,
293297
long=long,
298+
manager=manager,
294299
)
295300

296301
# pylint: disable=too-many-locals

dash/dash.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,9 +1194,6 @@ def dispatch(self):
11941194
input_values
11951195
) = inputs_to_dict(inputs)
11961196
g.state_values = inputs_to_dict(state) # pylint: disable=assigning-non-slot
1197-
g.background_callback_manager = (
1198-
self._background_manager
1199-
) # pylint: disable=E0237
12001197
changed_props = body.get("changedPropIds", [])
12011198
g.triggered_inputs = [ # pylint: disable=assigning-non-slot
12021199
{"prop_id": x, "value": input_values.get(x)} for x in changed_props
@@ -1211,7 +1208,9 @@ def dispatch(self):
12111208
try:
12121209
cb = self.callback_map[output]
12131210
func = cb["callback"]
1214-
1211+
g.background_callback_manager = (
1212+
cb.get("manager") or self._background_manager
1213+
)
12151214
g.ignore_register_page = cb.get("long", False)
12161215

12171216
# Add args_grouping
@@ -1316,21 +1315,26 @@ def _setup_server(self):
13161315

13171316
_validate.validate_long_callbacks(self.callback_map)
13181317

1319-
cancels = set()
1318+
cancels = {}
13201319

13211320
for callback in self.callback_map.values():
1322-
cancel = callback.get("long", {}).pop("cancel_inputs")
1321+
long = callback.get("long")
1322+
if not long:
1323+
continue
1324+
cancel = long.pop("cancel_inputs")
13231325
if cancel:
1324-
cancels.update(cancel)
1326+
for c in cancel:
1327+
cancels[c] = long.get("manager")
13251328

13261329
if cancels:
1327-
for cancel_input in cancels:
1330+
for cancel_input, manager in cancels.items():
13281331

13291332
# pylint: disable=cell-var-from-loop
13301333
@self.callback(
13311334
Output(cancel_input.component_id, "id"),
13321335
cancel_input,
13331336
prevent_initial_call=True,
1337+
manager=manager,
13341338
)
13351339
def cancel_call(*_):
13361340
job_ids = flask.request.args.getlist("cancelJob")

0 commit comments

Comments
 (0)