Mar-06-2022, 11:12 PM
i want to wait for the first event to happen of these two events
1. the time one second in the future. just doing time.sleep() is not usable since it cannot wake up on other events while asleep.
2. data sent over a pipe written to the other end by a child process. i need to read this data as soon as it is written. this data is the output from the ping command.
the use case is to immediately detect when there is an N second gap between the ping command results.
the first idea i had was two processes doing the writing over the same pipe. that way my code can just do a read from the pipe and get whatever comes next. i just need to make the data distinguishable, which is trivial to do (make the time not look like ping output). the issue for me is that it seems rather wasteful to use a whole process to write the time every second.
the one thing i find so difficult in every programming model i have seen is the ability to wait for two different events to immediately ake up on which event happens next without knowing which it will be. can Python handle this with just one child process (ping)?
1. the time one second in the future. just doing time.sleep() is not usable since it cannot wake up on other events while asleep.
2. data sent over a pipe written to the other end by a child process. i need to read this data as soon as it is written. this data is the output from the ping command.
the use case is to immediately detect when there is an N second gap between the ping command results.
the first idea i had was two processes doing the writing over the same pipe. that way my code can just do a read from the pipe and get whatever comes next. i just need to make the data distinguishable, which is trivial to do (make the time not look like ping output). the issue for me is that it seems rather wasteful to use a whole process to write the time every second.
the one thing i find so difficult in every programming model i have seen is the ability to wait for two different events to immediately ake up on which event happens next without knowing which it will be. can Python handle this with just one child process (ping)?
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.