
    h$                    ~    S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	J
r
   " S S5      r S         SS	 jjrSS
/rg)z*0MQ polling related functions and classes.    )annotations)Any)zmq_poll)POLLERRPOLLINPOLLOUTc                      \ rS rSr% SrS\S'   S\S'   SS jrSS jr\\	-  4SS	 jjr
\\	-  4S
 jrSS jrSSS jjrSrg)Poller   z>A stateful poll interface that mirrors Python's built-in poll.list[tuple[Any, int]]socketsdict_mapc                     / U l         0 U l        g N)r   r   )selfs    aC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\zmq/sugar/poll.py__init__Poller.__init__   s    	    c                    XR                   ;   $ r   )r   )r   sockets     r   __contains__Poller.__contains__   s    ""r   c                2   U(       ao  XR                   ;   a   U R                   U   nX4U R                  U'   g[        U R                  5      nU R                  R                  X45        X0R                   U'   gXR                   ;   a  U R	                  U5        gg)a  p.register(socket, flags=POLLIN|POLLOUT)

Register a 0MQ socket or native fd for I/O monitoring.

register(s,0) is equivalent to unregister(s).

Parameters
----------
socket : zmq.Socket or native socket
    A zmq.Socket or any Python object having a ``fileno()``
    method that returns a valid file descriptor.
flags : int
    The events to watch for.  Can be POLLIN, POLLOUT or POLLIN|POLLOUT.
    If `flags=0`, socket will be unregistered.
N)r   r   lenappend
unregister)r   r   flagsidxs       r   registerPoller.register   sx      "ii'%+OS!$,,'##VO4$'		&!yy OOF# r   c                &    U R                  X5        g)zCModify the flags for an already registered 0MQ socket or native fd.N)r!   )r   r   r   s      r   modifyPoller.modify>   s    f$r   c                    U R                   R                  U5      nU R                  R                  U5        U R                  US  H  u  pU R                   U==   S-  ss'   M     g)zRemove a 0MQ socket or native fd for I/O monitoring.

Parameters
----------
socket : Socket
    The socket instance to stop polling.
N   )r   popr   )r   r   r    r   s       r   r   Poller.unregisterB   sS     iimmF#!\\#$/MFIIf" 0r   Nc                    Ub  US:  a  SnO [        U[        5      (       a  [        U5      n[        U R                  US9$ )aG  Poll the registered 0MQ or native fds for I/O.

If there are currently events ready to be processed, this function will return immediately.
Otherwise, this function will return as soon the first event is available or after timeout
milliseconds have elapsed.

Parameters
----------
timeout : int
    The timeout in milliseconds. If None, no `timeout` (infinite). This
    is in milliseconds to be compatible with ``select.poll()``.

Returns
-------
events : list
    The list of events that are ready to be processed.
    This is a list of tuples of the form ``(socket, event_mask)``, where the 0MQ Socket
    or integer fd is the first element, and the poll event mask (POLLIN, POLLOUT) is the second.
    It is common to call ``events = dict(poller.poll())``,
    which turns the list of tuples into a mapping of ``socket : event_mask``.
r   )timeout)
isinstancefloatintr   r   )r   r,   s     r   pollPoller.pollP   s;    , ?gkG'''lGg66r   )r   r   )returnNone)r   r   r2   bool)r   r   r   r/   )r   r   r   )r,   z
int | Noner2   r   )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r!   r$   r   r0   __static_attributes__ r   r   r
   r
      sG    H""
J# 28'1A > $*G#3 %#7 7r   r
   Nc                   Uc  Sn[        US-  5      nUS:  a  Sn/ n[        X-   U-   5       HA  nSnXP;   a	  U[        -  nXQ;   a	  U[        -  nXR;   a	  U[        -  nUR                  XV45        MC     [        XC5      n/ / / p!n U Hd  u  pVU[        -  (       a  U R                  U5        U[        -  (       a  UR                  U5        U[        -  (       d  MS  UR                  U5        Mf     XU4$ )a  select(rlist, wlist, xlist, timeout=None) -> (rlist, wlist, xlist)

Return the result of poll as a lists of sockets ready for r/w/exception.

This has the same interface as Python's built-in ``select.select()`` function.

Parameters
----------
timeout : float, optional
    The timeout in seconds. If None, no timeout (infinite). This is in seconds to be
    compatible with ``select.select()``.
rlist : list
    sockets/FDs to be polled for read events
wlist : list
    sockets/FDs to be polled for write events
xlist : list
    sockets/FDs to be polled for error events

Returns
-------
rlist: list
    list of sockets or FDs that are readable
wlist: list
    list of sockets or FDs that are writable
xlist: list
    list of sockets or FDs that had error events (rare)
r+   g     @@r   )r/   setr   r   r   r   r   )rlistwlistxlistr,   r   sr   return_socketss           r   selectrD   m   s    <  'F"#G{G&':VOE:WE:WEz" ( g/Nb"%E"6>LLO7?LLO7??LLO # r   rD   r   )
r?   listr@   rE   rA   rE   r,   zfloat | Noner2   ztuple[list, list, list])r9   
__future__r   typingr   zmq.backendr   zmq.constantsr   r   r   r
   rD   __all__r<   r   r   <module>rK      sg    0
 #    2 2X7 X7x DH888%)84@88~ X
r   