I have some Python code that I want to debug with perf. Now, the thing with perf is that it gives the output when the process is terminated, I want to do the same via a Python script.
perf stat -p <my_pid>
I want to run this inside a Python code in background, until some point where I want to be able to terminate its operation and print the commands output. To show what I mean:
x = subprocess.Popen(["perf","stat","-p",str(GetMyProcessID())], stdout = subprocess.PIPE)
.. CODE TO DEBUG ..
#Terminate the process and get the output after ??
Is something like this possible ?
EDIT: This is not a duplicate question, I have tried to refine my question and its title as I have more clear understanding about it right now.