diff --git a/distributed/utils.py b/distributed/utils.py index 74739c7be6..47ecee12f5 100644 --- a/distributed/utils.py +++ b/distributed/utils.py @@ -801,7 +801,7 @@ def _getmodulename_with_path(fname: str) -> str: except KeyError: pass - for modname, mod in sys.modules.items(): + for modname, mod in sys.modules.copy().items(): fname2 = getattr(mod, "__file__", None) if fname2: _getmodulename_with_path_map[fname2] = modname