From d2d036f3ec46875f6837b560721c0e5dc5e32354 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 15 Jul 2021 12:18:52 +0200 Subject: [PATCH 1/2] Fix race condition in autoreload --- panel/io/reload.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/panel/io/reload.py b/panel/io/reload.py index dc03e034b6..7abede8c02 100644 --- a/panel/io/reload.py +++ b/panel/io/reload.py @@ -113,11 +113,11 @@ def _reload(module=None): if module is not None: for module in _modules: del sys.modules[module] - if state.curdoc in _callbacks: - _callbacks[state.curdoc].stop() - del _callbacks[state.curdoc] - if state.location: - state.location.reload = True + for cb in _callbacks.values(): + cb.stop() + _callbacks.clear() + for loc in state._locations.values(): + loc.reload = True def _check_file(modify_times, path, module=None): try: From a384125a75350b78d36e12f37ef0bbf289d02024 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 15 Jul 2021 12:40:38 +0200 Subject: [PATCH 2/2] Fix test --- panel/io/reload.py | 1 + 1 file changed, 1 insertion(+) diff --git a/panel/io/reload.py b/panel/io/reload.py index 7abede8c02..9d4b8d2717 100644 --- a/panel/io/reload.py +++ b/panel/io/reload.py @@ -116,6 +116,7 @@ def _reload(module=None): for cb in _callbacks.values(): cb.stop() _callbacks.clear() + state.location.reload = True for loc in state._locations.values(): loc.reload = True