Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to do a two-way wait
#1
i did this once before. i'm still looking for that old code among 10000+ files. but i'm worried that code has some "clever" solution based on specific things it would wait for, probably done using lots of C-like syscalls. what i would like to know is a Pythonic way to wait for 2 or more things, to wake up when any one of them happens. i will not give specific examples to avoid replies based on those specific examples. i'm looking for general solutions to handle any case in Python.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
My guess is you're wanting to do something like the equivalent of a select() for when some file descriptors have data, or you're using some sort of multithreaded/multiprocessing/async framework. I don't think there's any generic "wait for something".
Reply
#3
your guess is on target.

i was thinking along the lines of some code that can wait for one of a list of 2 or more threads to quit. this function is passed a list of functions, each waits on the various things to wait on. the function launches a thread for each and waits for any one to quit. then it returns the index of which it was. the other threads probably should be killed.
Tradition is peer pressure from dead people

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


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
  wait for the first of these events Skaperen 4 1,966 Mar-07-2022, 08:46 PM
Last Post: Gribouillis
  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
  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