Make pyflame create output after itself being terminated #167
Description
Hi,
I am trying to use pyflame to profile requests to a web server.
The web server is written in Flask, so what I'm currently doing is adding a "before every request" hook which currently spawns a pyflame process and attaches to the Flask process using its own PID.
I then have an "after every request" hook which I want to use to terminate pyflame at the end of the request, and get my profiling information for that request.
Unfortunately, I've tried sending SIGTERM and various other signals, but pyflame does not seem to want to output anything until its full completion. It creates the output file, but I obviously cannot predict how long each request is going to run for, so currently I'm passing -s 60
as any request would time out after 60 seconds anyways.
I think it would be really useful to make pyflame to accept a SIGTERM signal which would cause it to spit out its output at the end. This is similar to #25 which makes pyflame spit out output when the process it is profiling terminates; however, I think terminating pyflame itself is also useful in cases like mine.
I cannot use the tracing (-t
) mode because my web server runs constantly instead of from start to finish - it is the requests that come and go and require individual profiling sessions.
If anyone has any advice on what I can do prior to having to modify pyflame myself, I'd be very grateful!
Many thanks,
Norbert