Skip to content

Commit 170670f

Browse files
authored
Don't crash when getting computation code in pathological cases (#8502)
1 parent df30dbf commit 170670f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

distributed/client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3095,8 +3095,12 @@ def _get_computation_code(
30953095
module_name = fr.f_back.f_globals["__name__"] # type: ignore
30963096
if module_name == "__channelexec__":
30973097
break # execnet; pytest-xdist # pragma: nocover
3098+
try:
3099+
module_name = sys.modules[module_name].__name__
3100+
except KeyError:
3101+
# Ignore pathological cases where the module name isn't in `sys.modules`
3102+
break
30983103
# Ignore IPython related wrapping functions to user code
3099-
module_name = sys.modules[module_name].__name__
31003104
if module_name.endswith("interactiveshell"):
31013105
break
31023106

0 commit comments

Comments
 (0)