From 50814e042dc8509087d072715b7cf506d02342da Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Mon, 9 May 2022 16:05:10 +0200 Subject: [PATCH] Obtain module name via a different strategy --- distributed/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/distributed/utils.py b/distributed/utils.py index 475ea836aa5..3bbae43213c 100644 --- a/distributed/utils.py +++ b/distributed/utils.py @@ -775,10 +775,13 @@ def __exit__(self, exc_type, exc_value, traceback): if not exc_type or issubclass(exc_type, (CommClosedError, gen.Return)): return - stack = inspect.stack() - frame = stack[self.unroll_stack] - mod = inspect.getmodule(frame[0]) - modname = mod.__name__ + i = self.unroll_stack + + while traceback.tb_next and i > 0: + traceback = traceback.tb_next + i -= 1 + + modname = traceback.tb_frame.f_globals["__name__"] try: logger = logging.getLogger(modname)