
    !ni                     H    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 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j0                  Zd Zej4                  ZddZy)os    Nsocket)S_ISREG)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       Q/home/homepc/tiktok-worker/venv/lib/python3.12/site-packages/eventlet/green/os.pyr   r      s^     b#2R788  1d1b11 qvvs   9 	AAAc                 ~   	 t         j                  |       j                  }t        |      s	 t	        j
                  | d       	 t        | |      S # t        j                  $ r Y yw xY w# t        $ rH}t        |      t        j                  k(  rY d}~yt        |      t        j                  k7  r Y d}~nd}~ww xY w)z;read(fd, buffersize) -> string

    Read a file descriptor.T)r    N)os_origstatst_moder   r	   
trampolineIOClosed__original_read__r   r   errnoEPIPEEAGAIN)r   nr"   r   s       r   r   r   %   s      ,,r"**w.	$R++	 == 
  	|u{{*|u||+ ,	 s/   A A* A'&A'*	B;3B6B66B;c                 Z   	 t         j                  |       j                  }t        |      s	 t	        j
                  | d       	 t        | |      S # t        j                  $ r Y yw xY w# t        $ r6}t        |      t        j                  t        j                  fvr Y d}~nd}~ww xY w)zPwrite(fd, string) -> byteswritten

    Write a string to a file descriptor.
    T)r   r   N)r    r!   r"   r   r	   r#   r$   __original_write__r   r   r&   r(   r'   )r   str"   r   s       r   r   r   ?   s    
  ,,r"**w$/	%b"--	 == 
  	|ELL%++#>> ?	 s)   A A* A'&A'*	B)3,B$$B)c                      t        dd      S )zDwait() -> (pid, status)

    Wait for completion of a child process.r   )r        r   r   r   U   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?)r    WNOHANG__original_waitpid__r   sleep)pidoptionsnew_optionsrpidstatuss        r   r   r   _   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moder;   r   s        r   r   r   r   se     Dz//$)4$=!eT6tUD@tUD1rIr/   )i  N)
__import__r    r&   r   r!   r   eventletr   eventlet.supportr   r   r	   eventlet.patcherr
   __all____patched__globalsdirr   r   r%   r   r+   r   r   r2   r   r>   r.   r/   r   <module>rK      s   
T
 	H	   &    -
//D IL		 LL . ]] ,  $  LL r/   