Re: select.poll and ppoll

2015-10-22 Thread Paul Rubin
Steven D'Aprano  writes:
> I have select.poll, but I'm looking for something like ppoll instead. From 
> the Linux man page:

I don't understand your post: do you have a question?

Also I thought the current preferred practice was to use epoll.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: select.poll and ppoll

2015-10-22 Thread Marko Rauhamaa
Steven D'Aprano :

> 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


Re: select.poll and ppoll

2015-10-22 Thread Laura Creighton
In a message of Thu, 22 Oct 2015 16:38:52 +1100, "Steven D'Aprano" writes:
>Using Python 2.6, don't hate me.

>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"

>-- 
>Steve
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list

Do you need alsa-mixer or would pulse-audio work for you?
Would this: https://github.com/mk-fg/pulseaudio-mixer-cli
do the job?

Laura (alsa-mixer hater)

-- 
https://mail.python.org/mailman/listinfo/python-list


select.poll and ppoll

2015-10-21 Thread Steven D'Aprano
Using Python 2.6, don't hate me.

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"



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list