Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>: > I have select.poll, but I'm looking for something like ppoll instead. From > the Linux man page: > > ppoll() > The relationship between poll() and ppoll() is analogous to the > relationship between select(2) and pselect(2): like pselect(2), > ppoll() allows an application to safely wait until either a file > descriptor becomes ready or until a signal is caught. > > Technically, *I* don't want this, it's one of my work-colleagues. He > says: > > "My high-level goal is to run a callback function whenever the alsa > mixer level changes. The C alsa API provides > snd_mixer_elem_set_callback, but the Python API (import alsaaudio) > seems to need me to get poll(2) descriptors"
I've never used ppoll or pselect. They are used to fix naive signal handling in a main loop: while not signaled: select.poll(...) ... The loop suffers from a race condition: the "signaled" flag, which is set by a signal handler, might change between "while" and "select.poll". The standard, classic way to solve the race condition is to replace the "signaled" flag with an internal pipe. The signal handler writes a byte into the pipe and select.poll() wakes up when the pipe becomes readable. IOW, ppoll() and pselect() are not needed. Marko -- https://mail.python.org/mailman/listinfo/python-list