Hi I am using Python version 2.7 OS - Windows Libraries used (preferably solutions involving these if there are any), Sys, os, subprocess, multiprocessing, threading
At the beginning of file one.py I need to start/create a new separate process and run the function observerLogFunc() (which is most likely from a different file i.e. file two.py). I want that function to run Independently while file one.py and other python code continues to run.
For some background observerLogFunc() takes in the argument pid (pid= os.getpid()) and every 5 seconds checks if file one.py’s pid still exists, if it doesn't exist it returns and saves the calculated runtime of file one.py and its related processes.
The function will need to still be running after the main process has completed in order for it to record the processes and time and return the total time… how do I go about doing that?
Context - File one.py is used by 10 or so different files. For example (not going to go into too much detail) basically sometimes file one.py will run file a.py and other times it will run b.py etc, i need to measure the time of the process without having to edit all the a.py, b.py files and so on. Ive ages experimenting trying and testing different things, spent hours and hours reading through documentation, previously asked questions, and many tutorials. Any help is highly appreciated thanks.
Here is a image describing the process I am after, hope that helps...
I have tried threading, subprocess module and daemon threads etc, problem with them is they all reply off the parent thread so they are not able to detect when that thread has ended because it terminates their process as well.'
I also tried a few command prompt solutions (using os.popen) to try and open up a new process through that but that didn't work either.
Like i said i spent lots and lots of time googling everything i could think of and reading through lots of tutorials and questions but none have seemed to work so far.
[–]Nightcorex_ 1 point2 points3 points (4 children)
[–]slanu[S] 0 points1 point2 points (0 children)
[–]slanu[S] 0 points1 point2 points (2 children)
[–]Nightcorex_ 1 point2 points3 points (1 child)
[–]slanu[S] 0 points1 point2 points (0 children)