a
8g+^ ã @ s\ d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlmZ G dd „ d e ƒZ
dS )
z•
pyudev._os.poll
===============
Operating system interface for pyudev.
.. moduleauthor:: Sebastian Wiesner
é )Úabsolute_import)Údivision)Úprint_function)Úunicode_literalsN)Úeintr_retry_callc @ sP e Zd ZdZejejdœZedd„ ƒZ e
dd„ ƒZdd„ Zdd
d„Z
dd
„ Zd S )ÚPollzwA poll object.
This object essentially provides a more convenient interface around
:class:`select.poll`.
)ÚrÚwc C s | |@ dkS )Nr © )ÚeventsÚeventr
r
ú3/usr/lib/python3.9/site-packages/pyudev/_os/poll.pyÚ
_has_event. s zPoll._has_eventc G sJ t tjƒ}|D ]2\}}| j |¡}|s4td |¡ƒ‚| ||¡ q| |ƒS )aG Listen for ``events``.
``events`` is a list of ``(fd, event)`` pairs, where ``fd`` is a file
descriptor or file object and ``event`` either ``'r'`` or ``'w'``. If
``r``, listen for whether that is ready to be read. If ``w``, listen
for whether the channel is ready to be written to.
zUnknown event type: {0!r})r ÚselectÚpollÚ_EVENT_TO_MASKÚgetÚ
ValueErrorÚformatÚregister)Úclsr ÚnotifierÚfdr Úmaskr
r
r
Ú
for_events2 s
zPoll.for_eventsc C s
|| _ dS )z›Create a poll object for the given ``notifier``.
``notifier`` is the :class:`select.poll` object wrapped by the new poll
object.
N)Ú _notifier)Úselfr r
r
r
Ú__init__D s z
Poll.__init__Nc C s t | t| jj|ƒ¡ƒS )a{ Poll for events.
``timeout`` is an integer specifying how long to wait for events (in
milliseconds). If omitted, ``None`` or negative, wait until an event
occurs.
Return a list of all events that occurred before ``timeout``, where
each event is a pair ``(fd, event)``. ``fd`` is the integral file
descriptor, and ``event`` a string indicating the event type. If
``'r'``, there is data to read from ``fd``. If ``'w'``, ``fd`` is
writable without blocking now. If ``'h'``, the file descriptor was
hung up (i.e. the remote side of a pipe was closed).
)ÚlistÚ
_parse_eventsr r r )r Útimeoutr
r
r
r M s ÿz Poll.pollc c s” |D ]Š\}}| |tj¡r*td |¡ƒ‚n| |tj¡rFtd |¡ƒ‚| |tj¡r^|dfV | |tj¡rv|dfV | |tj¡r|dfV qdS )z˜Parse ``events``.
``events`` is a list of events as returned by
:meth:`select.poll.poll()`.
Yield all parsed events.
zFile descriptor not open: {0!r}zError while polling fd: {0!r}r r ÚhN) r r ZPOLLNVALÚIOErrorr ZPOLLERRÚPOLLINÚPOLLOUTZPOLLHUP)r r r Z
event_maskr
r
r
r a s
zPoll._parse_events)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r# r$ r Ústaticmethodr Úclassmethodr r r r r
r
r
r
r $ s
r )r( Z
__future__r r r r r Zpyudev._utilr Úobjectr r
r
r
r
Ú s