Open wumpus opened 4 years ago
I think this is a great idea - we just need support for discovering the python processes running on the system first, which will require some OS specific code.
I think this should be pretty straightforward to add to the remoteprocess crate though: on linux using procfs, windows with the EnumProcesses win32 api call, OSX with a KERN_PROC_ALL sysctl call etc (don't know how to do with FreeBSD off the top of my head - but I'm sure we can figure it out =).
I like the idea about just inferring the python process if there is only one running - for multiple we could show pids, and also accept matches on the process commandline (so like py-spy top -p my_python_program.py
would pick up the right python process).
@wumpus but that's the job of your shell/GNU tools, not py-spy, e.g.: py-spy top --pid (pgrep python)
and py-spy top --pid (pgrep python | fzf)
Yeah, people always tell me I'm not very good at using the shell, after 34 years.
By the way, your solutions only address part of what I was suggesting, and are impossible to read over the phone.
I was attempting to talk my boss through using
py-spy top
on his long-running process ("ok type ps, now note the pid of your python process, then..."), and it struck me that almost all of the time that I want to runpy-spy top
, I have exactly one python process.So... why not
py-spy top --pid auto
or even plainpy-spy top
? And if there's more than one python process for my userid, print useful output so that I can cut-n-paste something without having to run ps?