Dec-29-2017, 07:52 AM
i want to start a command every 10 seconds and capture its stdout output as it is produced. each command could be done in as short a time as 9 seconds or as long a time as 19 seconds. the exact command is ['ping','-c','10',address]. i want to be sure the next command process is started exactly 10 seconds after the previous command process was started, regardless when any processes quit. this means there could be some time that no processes are running and there could be some that that two processes are running. i also want to leave open the possibility that it could run even longer than 19 seconds, so there could be many processes running in extreme cases. the loop starting these processes will run indefinitely, possibly for several months. i also want to not leave any processes in a <defunct> state for more than a few seconds, certainly not collecting a bunch of them.
i could go about doing this with a bunch of module os functions to do it just like i have done this before in the C language. but i would like to find a more pythonic way of achieving this. i have tried some function in module multiprocessing and in module subprocess, but these have always run into problems like a growing pile of defunct processes or the whole thing just being hung and stop running. i would run the ping command indefinitely except that it drifts in time regardless. the ping rate is effectively a few milliseconds long than 1 second. by starting an N second ping every N seconds i can keep the average rate held to exactly one second with only a small amount of jitter for more accurate long-scale analysis in real time.
i could go about doing this with a bunch of module os functions to do it just like i have done this before in the C language. but i would like to find a more pythonic way of achieving this. i have tried some function in module multiprocessing and in module subprocess, but these have always run into problems like a growing pile of defunct processes or the whole thing just being hung and stop running. i would run the ping command indefinitely except that it drifts in time regardless. the ping rate is effectively a few milliseconds long than 1 second. by starting an N second ping every N seconds i can keep the average rate held to exactly one second with only a small amount of jitter for more accurate long-scale analysis in real time.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.