Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Make pyflame create output after itself being terminated #167

Open
Norbo11 opened this issue Feb 12, 2019 · 1 comment
Open

Make pyflame create output after itself being terminated #167

Norbo11 opened this issue Feb 12, 2019 · 1 comment

Comments

@Norbo11
Copy link

Norbo11 commented Feb 12, 2019

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

@Norbo11 Norbo11 changed the title Invoking pyflame programmatically for an undefined period of time Make pyflame create output after itself being terminated Feb 12, 2019
@Norbo11
Copy link
Author

Norbo11 commented Feb 12, 2019

I believe #163 is doing just that!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant