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
I was wandering if there is a way to get the cpu time of a process just before it dies?
It could be possible with a thread that monitors it with a p.cpu_times(),
but is there a way to get it in a one shot?
Thanks
The text was updated successfully, but these errors were encountered:
If you need to do this for your own process (or its children) just register a signal handler (a callable) for SIGTERM (check signal.signal), then do whatever you have to do in there.
Incidentally doing that "right" can be kinda tricky, but fortunately for you I wrote a recipe exactly for doing that. =) http://grodola.blogspot.com/2016/02/how-to-always-execute-exit-functions-in-py.html
If you're on Windows this may be troublesome as signals don't work the same way as on UNIX (basically they suck).
If you need to do this for a PID/process which is not owned by you then there's no way to do this.
I was wandering if there is a way to get the cpu time of a process just before it dies?
It could be possible with a thread that monitors it with a
p.cpu_times()
,but is there a way to get it in a one shot?
Thanks
The text was updated successfully, but these errors were encountered: