You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose I have a python program program.py that exits with sys.exit(1) or by raising an exception. If I run py-spy record -- python program.py, this gives an exit code of 0. There's clearly a way in which this makes sense — the profile was correctly written, and if I had profiled the program with --pid then I would expect an exit code of 0 from py-spy even if the Python program had errored. But still, in this case of running without --pid, I would like some way to see the exit code of the Python program (e.g., by having it written to a file).
Is there some way of getting the exit code that I've overlooked? A roundabout way I can think of is to write a wrapper script that runs program.py as a subprocess and writes the exit code somewhere, and then I could run py-spy record --subprocesses on the wrapper.
(My use case here: I'm using py-spy to profile jobs on Kubernetes — in fact, py-spy is low enough overhead that I wanted to make every job I launch for my project to go through py-spy. I cannot use --pid because the pod security settings of my Kubernetes cluster do not allow me to add the SYS_PTRACE capability, so I run something like py-spy record -- python program.py in my jobs. But this means that if my programs error, the exit code is still 0 and the Kubernetes job is not marked as errored.)
Versions
Ubuntu 22.04
py-spy 0.3.14
python 3.10.14
And this issue still holds for this other combination of versions:
MacOS 15.0.1
py-spy 0.3.14, or built from main
python 3.11.4
The text was updated successfully, but these errors were encountered:
Suppose I have a python program
program.py
that exits withsys.exit(1)
or by raising an exception. If I runpy-spy record -- python program.py
, this gives an exit code of 0. There's clearly a way in which this makes sense — the profile was correctly written, and if I had profiled the program with--pid
then I would expect an exit code of 0 frompy-spy
even if the Python program had errored. But still, in this case of running without--pid
, I would like some way to see the exit code of the Python program (e.g., by having it written to a file).Is there some way of getting the exit code that I've overlooked? A roundabout way I can think of is to write a wrapper script that runs program.py as a subprocess and writes the exit code somewhere, and then I could run
py-spy record --subprocesses
on the wrapper.(My use case here: I'm using py-spy to profile jobs on Kubernetes — in fact, py-spy is low enough overhead that I wanted to make every job I launch for my project to go through py-spy. I cannot use
--pid
because the pod security settings of my Kubernetes cluster do not allow me to add theSYS_PTRACE
capability, so I run something likepy-spy record -- python program.py
in my jobs. But this means that if my programs error, the exit code is still 0 and the Kubernetes job is not marked as errored.)Versions
And this issue still holds for this other combination of versions:
main
The text was updated successfully, but these errors were encountered: