Skip to content

Conversation

@mgmacias95
Copy link
Contributor

@mgmacias95 mgmacias95 commented Dec 23, 2025

This script shows the error trace when a profiled script (or python module) in the live mode fails.

Some output examples:

When running a script that fails inmediately, the live mode won't even start and you'll see the traceback directly instead:

mgmacias@mgmacias:~/cpython$ cat failing_script.py 
1/0
mgmacias@mgmacias:~/cpython$ ./python -m profiling.sampling run --live -d999999 failing_script.py 
No samples collected - process 1464940 exited before profiling could begin.
Traceback (most recent call last):
  File "<frozen runpy>", line 196, in _run_module_as_main
  File "<frozen runpy>", line 87, in _run_code
  File "/home/mgmacias/cpython/Lib/profiling/sampling/_sync_coordinator.py", line 256, in <module>
    main()
    ~~~~^^
  File "/home/mgmacias/cpython/Lib/profiling/sampling/_sync_coordinator.py", line 249, in main
    _execute_script(script_path, script_args, cwd)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgmacias/cpython/Lib/profiling/sampling/_sync_coordinator.py", line 196, in _execute_script
    exec(code, main_module.__dict__)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mgmacias/cpython/failing_script.py", line 1, in <module>
    1/0
    ~^~
ZeroDivisionError: division by zero

When running a test that doesn't exist, you will see a brief profiled information and when exiting the live mode you'll see this traceback:

mgmacias@mgmacias:~/cpython$ ./python -m profiling.sampling run --live -d999999 -m test test_dfgdfg
test test_dfgdfg crashed -- Traceback (most recent call last):
  File "/home/mgmacias/cpython/Lib/test/libregrtest/single.py", line 210, in _runtest_env_changed_exc
    _load_run_test(result, runtests)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/mgmacias/cpython/Lib/test/libregrtest/single.py", line 155, in _load_run_test
    test_mod = importlib.import_module(module_name)
  File "/home/mgmacias/cpython/Lib/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1303, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1276, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1240, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'test.test_dfgdfg'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant