Python Forum
wait for the first of these events
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wait for the first of these events
#1
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)?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
wait for the first of these events - by Skaperen - Mar-06-2022, 11:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wait til a date and time KatManDEW 2 1,460 Mar-11-2022, 08:05 PM
Last Post: KatManDEW
  how to do a two-way wait Skaperen 2 1,297 Mar-04-2022, 02:31 AM
Last Post: Skaperen
  Run an app in a standalone terminal and wait until it's closed glestwid 2 2,554 Aug-30-2020, 08:14 AM
Last Post: glestwid
  python os.popen is not working for wait method elenaflorence87 0 2,025 Jul-22-2020, 12:56 PM
Last Post: elenaflorence87
  Wait for command within a process bRitch022 1 3,287 Jul-15-2020, 07:03 PM
Last Post: bRitch022
  Simulating events using Hawkes akshit2291 1 2,164 Sep-25-2018, 04:17 AM
Last Post: Larz60+
  win32com Events not catching dageci 0 3,775 Aug-06-2018, 03:18 PM
Last Post: dageci
  Subprocess.send_signal, wait until completion plinio 5 9,118 Jun-29-2018, 12:07 PM
Last Post: plinio
  just a trial. Please wait 5 minutes before deleting this thread sylas 2 3,461 Jun-06-2017, 03:34 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020