#632·scalene

Signal Scalene to report what it has gathered

Author: garethkyCreated Jun 29, 2023Updated May 29, 2025

Is your feature request related to a problem? Please describe. I'm trying to use Scalene to profile a large, multi threaded, Python program that's designed to be a system service. The only way the service exits is via the shutdown command. There is no internal way to cleanly exit the service. When testing on the command like I have to kill the process to make it exit.

Basically I need a profiling report from a chunk of runtime of a program without the program having to exit.

Describe the solution you'd like I'd like a way to signal to Scalene that it should prepare the report based on the data it has already gathered and write it to the output file. Something like:

$ scalene --profile-all --outfile ~/profile.json service.py &
$ python3 -m scalene.profile --off --pid 1337
$ echo "10 minutes later..."
$ python3 -m scalene.profile --off --pid 1337
$ python3 -m scalene.profile --report --pid 1337

and the report shows up at ~/profile.json immediately.

If I later toggle the profiling and ask for a report, it will be a new report for the new chunk of runtime that was profiled.

Describe alternatives you've considered The only way I can get output from this program is with --profile-interval

Additional context The service in question is the open source klipper 3D printer 'firmware', which is mainly written in Python.

I think other people have tried to ask for this but they didn't make clear what they needed. Some have asked to connect Scalene to a running process. This is a way to get a report without having to capture the entire run of the program or wait for it to exit to see results.