
    <|h3                        d Z ddlmZmZmZ ddlZddlZddlm	Z	 ddl
mZ ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ej                  Zej0                  j3                  d      rd ZneZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dgZ% e&ed      re%jO                  d       ndgZ(dge%z   Z)ejT                  Z* ee e+       e)d      Z,dZ-dZ.d Z/ G d de0      Z1d$dZ G d  d!e0      Z2 G d" de0      Z3d# Z4y)%z
Waiting for I/O completion.
    )absolute_importdivisionprint_functionN)Event)_get_hub_noargs)sleep)integer_types)	iteritems)copy_globals)_NONE)EINTRwin32c                 ,    | s|s|syt        | |||      S )N r   r   )_real_original_select)rwxts       L/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/select.py_original_selectr      s     1$Q1a00                       @         selectpollerrorr   )names_to_ignoredunder_names_to_keepc                     	 | j                   } |       S # t        $ r# t        | t              st	        d|       | cY S w xY w)Nz4argument must be an int, or have a fileno() method: )filenoAttributeError
isinstancer	   	TypeError)objfileno_fs     r   
get_filenor/   B   sI    ::
 :	  #}-X[]^^
s    )A Ac                   F    e Zd ZdZed        Zed        Zed        Zd Z	y)SelectResultr   c                 $      fd}||_         |S )Nc                 h    j                  |        |j                          j                          y N)appendcloseset)fdwatchereventready_collections     r   cbz'SelectResult._make_callback.<locals>.cbQ   s#    ##B'MMOIIKr   )mask)r;   r:   r=   r<   s   ``  r   _make_callbackzSelectResult._make_callbackO   s    	 	r   c                 T   t               j                  }|j                  }|j                  }|D ]T  \  }}	 |D ]I  } |t	        |      |j
                        }	||	_        |j                  |	       |	j                  |||	       K V y # t        $ r}
t        |
j                   d }
~
ww xY wr4   )get_hubloopioMAXPRIr/   r=   priorityr5   startIOErrorr%   args)clswatchersfd_cbrA   rB   rC   fdlistcallbackr8   r9   exs              r   _make_watcherszSelectResult._make_watchersX   s    y~~WW % 	&FH&  9B B?G'-G$OOG,MM(B8	9	&  &RWWo%&s   AB	B'B""B'c                 \    | D ]"  }|j                          |j                          $ | d d = y r4   )stopr6   )rI   r9   s     r   	_closeallzSelectResult._closeallh   s,     	GLLNMMO	 QKr   c                 *   g }g }g }t               }| j                  ||t              }| j                  ||t              }		 | j	                  |||f||	f       |j                  |       ||g f| j                  |       S # | j                  |       w xY w)Ntimeout)r   r>   _EV_READ	_EV_WRITErN   waitrQ   )
selfrlistwlistrT   rI   readwriter:   add_read	add_writes
             r   r#   zSelectResult.selecto   s     &&tUH=''ui@		%!& 1!&	 24 JJwJ'?NN8$DNN8$s    -A? ?BN)
__name__
__module____qualname__	__slots__staticmethodr>   classmethodrN   rQ   r#   r   r   r   r1   r1   L   sF    I  & &  %r   r1   c                    ||dk  rt        d      t        | t        t        f      r| n
t        |       } t        |t        t        f      r|n
t        |      }d}	 t	        | ||d      }|d   s|d   s|d   s||dk(  rt                |S t               }|j                  | ||      S # t
        $ r2}t        |dd      xs |j                  d   }|t        k7  r Y d}~ud}~ww xY w)a  An implementation of :obj:`select.select` that blocks only the current greenlet.

    .. caution:: *xlist* is ignored.

    .. versionchanged:: 1.2a1
       Raise a :exc:`ValueError` if timeout is negative. This matches Python 3's
       behaviour (Python 2 would raise a ``select.error``). Previously gevent had
       undefined behaviour.
    .. versionchanged:: 1.2a1
       Raise an exception if any of the file descriptors are invalid.
    Nr   ztimeout must be non-negativer   errnor   r   )
ValueErrorr+   listtupler   r%   getattrrG   r   _g_sleepr1   r#   )rY   rZ   xlistrT   sel_resultseenumberresults           r   r#   r#      s     w{ 788  e}5E4;Ee}5E4;E K&ueUA> 1~Q;q>g>QV]abVb 	
^F==w///  !Wd+8qvvaye s   B) )	C$2(CC$c                       e Zd ZdZd Zd Zy)
PollResult)eventsr:   c                 @    t               | _        t               | _        y r4   )r7   rs   r   r:   rX   s    r   __init__zPollResult.__init__   s    eW
r   c                     |dk  rt         }n#d}|t        z  rt        }|t        z  r	|t        z  }| j
                  j                  ||f       | j                  j                          y )Nr   )	POLLNVALrU   POLLINrV   POLLOUTrs   addr:   r7   )rX   rs   r8   result_flagss       r   	add_eventzPollResult.add_event   sU    A:#LL %	!'\*+

r   N)r_   r`   ra   rb   rv   r}   r   r   r   rr   rr      s    #Ir   rr   c                   :    e Zd ZdZd ZefdZd Zd Zd	dZ	d Z
y)
r$   a  
    An implementation of :obj:`select.poll` that blocks only the current greenlet.

    With only one exception, the interface is the same as the standard library interface.

    .. caution:: ``POLLPRI`` data is not supported.

    .. versionadded:: 1.1b1
    .. versionchanged:: 1.5
       This is now always defined, regardless of whether the standard library
       defines :func:`select.poll` or not. Note that it may have different performance
       characteristics.
    c                 D    i | _         t               j                  | _        y r4   )fdsr@   rA   ru   s    r   rv   zpoll.__init__   s    
 INN	r   c                     |t         u rt        t        z  }n#d}|t        z  rt        }|t        z  r	|t        z  }t        |      }|| j                  |<   y)a  
        Register a file descriptor *fd* with the polling object.

        Future calls to the :meth:`poll`` method will then check
        whether the file descriptor has any pending I/O events. *fd* can
        be either an integer, or an object with a ``fileno()`` method that
        returns an integer. File objects implement ``fileno()``, so they
        can also be used as the argument (but remember that regular
        files are usually always ready).

        *eventmask* is an optional bitmask describing the type of events
        you want to check for, and can be a combination of the
        constants ``POLLIN``, and ``POLLOUT`` (``POLLPRI`` is not supported).
        r   N)r   rU   rV   ry   rz   r/   r   )rX   r8   	eventmaskflagsr)   s        r   registerzpoll.register   sS     y(EE6! 7"" B r   c                 (    | j                  ||       y)zA
        Change the set of events being watched on *fd*.
        N)r   )rX   r8   r   s      r   modifyzpoll.modify  s     	b)$r   c                 d   g }| j                   j                  }| j                   j                  }	 t        | j                        D ]:  \  }} |||      }|j                  |       ||_        |j                  ||d       < 	 |S #  |D ]"  }|j                          |j                          $  xY w)NT)pass_events)
rA   rB   rC   r
   r   r5   rD   rE   rP   r6   )	rX   
watcher_cbrI   rB   rC   r8   r   r9   awatchers	            r   _get_started_watcherszpoll._get_started_watchers  s    YY\\!!
	&txx0 @	ER-(#) j"$?	@ 	$ ! ! s   AB *B/Nc                 x   t               }| j                  |j                        }	 ||dk  rd}n|r|dz  }|j                  j	                  |       t        |j                        |D ]"  }|j                          |j                          $ S # |D ]"  }|j                          |j                          $ w xY w)aH  
        poll the registered fds.

        .. versionchanged:: 1.2a1
           File descriptors that are closed are reported with POLLNVAL.

        .. versionchanged:: 1.3a2
           Under libuv, interpret *timeout* values less than 0 the same as *None*,
           i.e., block. This was always the case with libev.
        Nr   g     @@rS   )	rr   r   r}   r:   rW   rh   rs   rP   r6   )rX   rT   rp   rI   r   s        r   r$   z	poll.poll1  s     --f.>.>?	!"Q; #G v%GLLg.&$ ! !H ! !s   AB )B9c                 4    t        |      }| j                  |= y)z
        Unregister the *fd*.

        .. versionchanged:: 1.2a1
           Raise a `KeyError` if *fd* was not registered, like the standard
           library. Previously gevent did nothing.
        N)r/   r   )rX   r8   r)   s      r   
unregisterzpoll.unregisterZ  s     BHHVr   r4   )r_   r`   ra   __doc__rv   r   r   r   r   r$   r   r   r   r   r$   r$      s+    # &+ !:%&'!R	r   c                 p    | j                   d   }| j                          |r| j                  dddd       y y )N
aggressiveepollkqueuekeventdevpoll)patch_kwargsdefault_patch_itemsremove_item)patch_requestr   s     r   _gevent_do_monkey_patchr   f  sB    ++L9J%%' 	!!		
	 r   r4   )5r   
__future__r   r   r   sysr#   
__select__gevent.eventr   
gevent.hubr   r@   r   rk   gevent._compatr	   r
   gevent._utilr   r   rf   r   r   platform
startswithr   ry   POLLPRIrz   POLLERRPOLLHUPrx   
POLLRDNORM
POLLRDBAND
POLLWRNORM
POLLWRBAND__implements__hasattrr5   	__extra____all__r%   globals__imports__rU   rV   r/   objectr1   rr   r$   r   r   r   r   <module>r      s6   A @ 
   1 ( ( $ %  ")) <<7#1 -
 








  :v&! 	I )n
$:wy+2024 	>%6 >%B@0H (~6 ~B
r   