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
#5
Skaperen Wrote:i am tying to avoid system specific code as much as i can.

I think the "pipe" terminology is confusing. If you start a child process with child = subprocess.Popen(...) and you wait for incoming data from child.stdout, this file object should work in the selectors module, so you could write OS agnostically (untested)
sel = selectors.DefaultSelector()
sel.register(child.stdout, selectors.EVENT_READ)
pairs = sel.select(timeout=1)
if pairs:
    data = child.stdout.readline()  # or perhaps read(1024) ?
    ...
else:
    # timed out
    # terminate child process ?
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wait til a date and time KatManDEW 2 1,439 Mar-11-2022, 08:05 PM
Last Post: KatManDEW
  how to do a two-way wait Skaperen 2 1,272 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,536 Aug-30-2020, 08:14 AM
Last Post: glestwid
  python os.popen is not working for wait method elenaflorence87 0 2,007 Jul-22-2020, 12:56 PM
Last Post: elenaflorence87
  Wait for command within a process bRitch022 1 3,264 Jul-15-2020, 07:03 PM
Last Post: bRitch022
  Simulating events using Hawkes akshit2291 1 2,145 Sep-25-2018, 04:17 AM
Last Post: Larz60+
  win32com Events not catching dageci 0 3,756 Aug-06-2018, 03:18 PM
Last Post: dageci
  Subprocess.send_signal, wait until completion plinio 5 9,083 Jun-29-2018, 12:07 PM
Last Post: plinio
  just a trial. Please wait 5 minutes before deleting this thread sylas 2 3,439 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