
    <|h                         d dl Z d dlZd dlmZ d dlmZ d dlmZmZ d dlmZ d dlm	Z	 d dlm
Z
 e j                  d    dk\  Zd	 Z G d
 de      Zedk(  r ej                           yy)    N)socket)testing)TestCasetcp_listener)gc_collect_if_needed)
skipOnPyPy)params   c                 h    	 | j                  |      }|J |       y # t        $ r t        sJ Y y w xY w)N)write
ValueErrorPY3)fsrs      Y/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/tests/test__greenio.py_write_to_closedr   "   s=    GGAJ y!y  
ss    11c                   .    e Zd Zd Z ed      d        Zy)TestGreenIoc                      fd} fd} fd}t               }t        j                  ||      } ||       |j                          t               }t        j                  ||      } ||       |j                          y )Nc                 l   	 | j                         \  }}|j                  d      }|j                          |j                  d       |j                          t	        |d       j                  t        j                  |j                  d       | j                          y # | j                          w xY w)Nwbmode   hello
   a   b)	acceptmakefilecloser   r   assertRaisesr   errorsendlistenerconn_fdselfs       r   accept_close_earlyz@TestGreenIo.test_close_with_makefile.<locals>.accept_close_early/   s    	!"//+a]]]-

$
 T*!!&,,		4@  s   BB! !B3c                    	 | j                         \  }}|j                  d      }|j                  d       |j                          |j	                  d       |j                          t        |d       j                  t        j                  |j                  d       | j                          y # | j                          w xY w)Nr   r   s   hello   
r   r   )	r   r   r   r    r#   r   r!   r   r"   r$   s       r   accept_close_latez?TestGreenIo.test_close_with_makefile.<locals>.accept_close_late=   s    
!"//+a]]]-"
		% 

 T*!!&,,		4@  s   BB2 2Cc                 T   t        j                  t        j                  | j	                         d   f      }|j                  d      }|j                          j                  |j                         d       j                  |j                                |j                          y )N   rbr   r   )r   create_connectionr	   DEFAULT_CONNECTgetsocknamer   r    assertEqualreadlineassertFalseread)serverclientr(   r)   s      r   did_it_workz9TestGreenIo.test_close_with_makefile.<locals>.did_it_workL   sy    --v/E/EvGYGYG[\]G^._`Fd+BLLNR[[]J7RWWY'HHJ    )r   geventspawnkill)r)   r*   r-   r:   r8   server_greenlets   `     r   test_close_with_makefilez$TestGreenIo.test_close_with_makefile-   sl    	!	!	  ,,'96BF ,,'8&AFr;   z6Takes multiple GCs and issues a warning we can't catchc                    dd l fd}t               }t        j                  ||       t	        j
                  t        j                  |j                         d   f      }t        j                  j                  d      5  |j                         }|j                          | j                  |j                         d       | j                  |j                         d       |j                          d d d        ~~y # 1 sw Y   ~~y xY w)Nr   c                    j                         5  j                  d       	 | j                         d   }|j                  d      }|j	                  d       |j                          t        |d       | j                          ~ ~t                t                	 d d d        y # | j                          ~ ~t                t                w xY w# 1 sw Y   y xY w)Nignorer   r   r   r   r   )catch_warningssimplefilterr   r   r   r    r   r   )r%   r&   warningss     r   accept_oncez7TestGreenIo.test_del_closes_socket.<locals>.accept_oncea   s     ((* +%%h/+#??,Q/D  ==d=3DJJz*JJL$T40NN$ (*(*!+ + NN$ (*(*!+ +s#   CAB'7&C'(CCCr/   g      ?zhello
 )rF   r   r<   r=   r   r1   r	   r2   r3   Timeout	start_newr   r    r4   r7   )r)   rG   r8   r9   r(   rF   s        @r   test_del_closes_socketz"TestGreenIo.test_del_closes_socket^   s    	+@ [&)))6+A+A6CUCUCWXYCZ*[\^^%%c* 	"BLLNRWWY	2 RWWY+HHJ	 	 s    A1C<<DN)__name__
__module____qualname__r@   r   rK    r;   r   r   r   +   s#    /b HI/ J/r;   r   __main__)sysr<   r   r   	greentestgevent.testingr   r   r   r   r	   version_infor   r   r   rL   mainrO   r;   r   <module>rV      se   &    ' 1 / % ! 
qQc( cL zINN r;   