
    CNh                     <    e d       ZddlZ e d      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g d	Z ee e       e ee      
       d Zej"                  Zd Zej&                  Zd Zd Zej,                  Zd Zej0                  ZddZy)os    Nsocket)greenio)	get_errno)greenthread)hubs)slurp_properties)fdopenreadwritewaitwaitpidopen)ignoresrckeysc                     t        | t              st        d| z        	 t        j                  | g|i |S # t
        $ r}t        |j                   d}~ww xY w)zrfdopen(fd [, mode='r' [, bufsize]]) -> file_object

    Return an open file object connected to a file descriptor.zfd should be int, not %rN)
isinstanceint	TypeErrorr   	GreenPipeOSErrorargs)fdr   kwes       3/usr/lib/python3/dist-packages/eventlet/green/os.pyr
   r
      s^     b#2R788  1d1b11 qvvs   9 	AAAc                 ,   	 	 t        | |      S # t        $ rH}t        |      t        j                  k(  rY d}~yt        |      t        j
                  k7  r Y d}~nd}~ww xY w	 t        j                  | d       n# t        j                  $ r Y yw xY w)z;read(fd, buffersize) -> string

    Read a file descriptor.TN )r   )	__original_read__r   r   errnoEPIPEEAGAINr   
trampolineIOClosed)r   nr   s      r   r   r   $   s     	$R++ 	|u{{*|u||+ ,	
	OOBT*}} 		 s+    	A AAA $A< <BBc                     	 	 t        | |      S # t        $ r6}t        |      t        j                  t        j
                  fvr Y d}~nd}~ww xY wt        j                  | d       g)zPwrite(fd, string) -> byteswritten

    Write a string to a file descriptor.
    TN)r   )__original_write__r   r   r    r"   r!   r   r#   )r   str   s      r   r   r   9   s_    
 	%b"-- 	|ELL%++#>> ?	 	$' s    	A,A		Ac                      t        dd      S )zDwait() -> (pid, status)

    Wait for completion of a child process.r   )r        r   r   r   G   s     1a=r+   c                     |t         j                  z  dk7  rt        | |      S |t         j                  z  }	 t        | |      \  }}|r	|dk\  r||fS t        j                  d       0)zjwaitpid(...)
    waitpid(pid, options) -> (pid, status)

    Wait for completion of a given child process.r   g{Gz?)os_origWNOHANG__original_waitpid__r   sleep)pidoptionsnew_optionsrpidstatuss        r   r   r   Q   si    
  A%#C11//[ALD&!V|#d#	 r+   c                     t        |       j                  dk(  r|||df\  } }}}|t        | |||      }nt        | ||      }t        j                  |       |S )zt Wrap os.open
        This behaves identically, but collaborates with
        the hub's notify_opened protocol.
    _NormalAccessorN)dir_fd)type__name____original_open__r   notify_opened)fileflagsmoder8   r   s        r   r   r   d   se     Dz//$)4$=!eT6tUD@tUD1rIr+   )i  N)
__import__r-   r    r   eventletr   eventlet.supportr   r   r   eventlet.patcherr	   __all____patched__globalsdirr
   r   r   r   r'   r   r   r/   r   r;   r*   r+   r   <module>rH      s   
T
 	H	  &    -
//D IL		 LL $ ]] (  $  LL r+   