-
Notifications
You must be signed in to change notification settings - Fork 39
Description
I am extremely out of my depth here, but I was unable to get proper tracebacks/debugging with dask.distributed clients because it would always complain NameError: name '__traceback_maker' is not defined (full traceback below).
I noticed that in tblib (3.2.2), the init.py file defines a __traceback_maker class:
# noinspection PyPep8Naming
class __traceback_maker(Exception):
pass
but it is never referenced directly, only through a compile call stub = compile('raise __traceback_maker', '<string>', 'exec',) (line 119).
I am not entirely sure why, but this means that when it gets to the exec() call on line 137 exec(code, dict(current.tb_frame.f_globals), dict(current.tb_frame.f_locals)) the traceback_maker class it not in f_globals nor f_locals, leading to the NameError.
If I manually add it to the globals dict:
globals_dict['__traceback_maker'] = __traceback_maker #new
exec(code, globals_dict, dict(current.tb_frame.f_locals)) # noqa: S102 [original line 119]
everything works as it should again.
Full traceback of initial error
Exception has occurred: NameError (note: full exception trace is shown but execution is paused at: errorFunction)
name '__traceback_maker' is not defined
File "F:\datatog\code\backend\410-groupstructure\410-groupstructure-parser.py", line 110, in errorFunction (Current frame)
raise ValueError(f'F --- IGNORE --- {i}')
^^^^^^^^^^^^^
File "C:\virtualenvs\datatog-venv\Lib\site-packages\tblib\__init__.py", line 137, in as_traceback
exec(code, dict(current.tb_frame.f_globals), dict(current.tb_frame.f_locals)) # noqa: S102
File "C:\virtualenvs\datatog-venv\Lib\site-packages\tblib\pickling_support.py", line 18, in unpickle_traceback
return ret.as_traceback()
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\protocol\pickle.py", line 95, in loads
return pickle.loads(x)
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\core.py", line 1721, in clean_exception
exception = protocol.pickle.loads(exception)
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\client.py", line 697, in set_error
_, exception, traceback = clean_exception(exception, traceback)
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\client.py", line 1844, in _handle_task_erred
state.set_error(exception, traceback)
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\client.py", line 1801, in _handle_report
result = handler(**msg)
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\utils.py", line 825, in wrapper
return await func(*args, **kwargs)
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\asyncio\events.py", line 89, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\asyncio\base_events.py", line 2050, in _run_once
handle._run()
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\asyncio\base_events.py", line 683, in run_forever
self._run_once()
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\asyncio\base_events.py", line 712, in run_until_complete
self.run_forever()
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\utils.py", line 578, in run_loop
asyncio_run(amain(), loop_factory=get_loop_factory())
File "C:\virtualenvs\datatog-venv\Lib\site-packages\distributed\utils.py", line 470, in wrapper
target()
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\threading.py", line 995, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\threading.py", line 1044, in _bootstrap_inner
self.run()
File "C:\Users\Jessa\AppData\Local\Python\pythoncore-3.13-64\Lib\threading.py", line 1015, in _bootstrap
self._bootstrap_inner()
NameError: name '__traceback_maker' is not defined