Re: Support for select exception filedescriptor set or POLLPRI/POLLERR?

203 views
Skip to first unread message

Artur Wroblewski

unread,
Feb 24, 2017, 1:05:33 PM2/24/17
to python...@googlegroups.com
(resurrecting very old thread)

David Jander wrote:
[...]
> One such example is the Linux GPIO sysfs interface. (see
> https://www.kernel.org/doc/Documentation/gpio/sysfs.txt for more info).
> Via this interface, one can manipulate digital input/output signals
> directly from user-space. One exceptionally (no pun intended) cool feature
> is the possibility of using inputs to trigger "software interrupts" in
> user-space via select() or poll().

> Probably this functionality would have to be implemented in the selectors
>module first by means of support for EVENT_EXCEPTION in addition to
> EVENT_READ and EVENT_WRITE.
[...]

I faced exactly the same problem few months ago.

Assuming you are using Linux... from epoll(2) manpage

Q3 Is the epoll file descriptor itself poll/epoll/selectable?
A3 Yes. If an epoll file descriptor has events waiting, then it will
indicate as being readable.

Therefore, you can monitor a GPIO sysfs file with custom epoll instance for
POLLPRI events, then monitor the instance with asyncio (or in other words,
the asyncio loop will notify you that the custom instance received a POLLPRI
event). Please see GPIO class constructor at

https://gitlab.com/wrobell/apgpio/blob/master/apgpio.py

Regards,

Artur

Sinan Nalkaya

unread,
Mar 2, 2017, 3:02:15 AM3/2/17
to python-tulip
As a yet another example written in twisted framework: https://github.com/sardok/txgpio


sinx.
Reply all
Reply to author
Forward
0 new messages