
    i                         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                     dS dS )    N)socket)testing)TestCasetcp_listener)gc_collect_if_needed)
skipOnPyPy)params   c                 ~    	 |                      |          }|
J |            d S # t          $ r t          sJ Y d S w xY w)N)write
ValueErrorPY3)fsrs      E/usr/local/lib/python3.11/dist-packages/gevent/tests/test__greenio.py_write_to_closedr   "   sW    GGAJJ yy!yyyyy    





s   % <<c                   <    e Zd Zd Z ed          d             ZdS )TestGreenIoc                 .     fd} fd} fd}t                      }t          j        ||          } ||           |                                 t                      }t          j        ||          } ||           |                                 d S )Nc                    	 |                                  \  }}|                    d          }|                                 |                    d           |                                 t	          |d                               t          j        |j        d           |                                  d S # |                                  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 B9 9Cc                    	 |                                  \  }}|                    d          }|                    d           |                                 |                    d           |                                 t          |d                               t          j        |j        d           |                                  d S # |                                  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   B5C C$c                    t          j        t          j        |                                 d         f          }|                    d          }|                                                     |                                d           	                    |
                                           |                                 d S )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   s    -v/EvGYGYG[G[\]G^._``Fd++BLLNNNR[[]]J777RWWYY'''HHJJJJJ    )r   geventspawnkill)r)   r*   r-   r:   r8   server_greenlets   `     r   test_close_with_makefilez$TestGreenIo.test_close_with_makefile-   s    	! 	! 	! 	! 	!	! 	! 	! 	! 	!	 	 	 	 	  ,'96BBF ,'8&AAFr;   z6Takes multiple GCs and issues a warning we can't catchc                 Z   dd l fd}t                      }t          j        ||           t	          j        t          j        |                                d         f          }t          j	        
                    d          5  |                                }|                                 |                     |                                d           |                     |                                d           |                                 d d d            n# 1 swxY w Y   ~~d S )Nr   c                 6                                    5                      d           	 |                                 d         }|                    d          }|                    d           |                                 t          |d           |                                  ~ ~t                       t                       n7# |                                  ~ ~t                       t                       w xY w	 d d d            d S # 1 swxY w Y   d S )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   sW    ((** + +%%h///+#??,,Q/D  ==d=33DJJz***JJLLL$T4000NN$$$ (***(****	 NN$$$ (***(*****!+ + + + + + + + + + + + + + + + + +s)   DA)C	3D	4C==DDD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^   sK   	+ 	+ 	+ 	+ 	+@ [&))))6+A6CUCUCWCWXYCZ*[\\^%%c** 	 	""BLLNNNRWWYY	222 RWWYY+++HHJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 BBs   BDD"%D"N)__name__
__module____qualname__r@   r   rK    r;   r   r   r   +   sL        / / /b ZHII/ / JI/ / /r;   r   __main__)sysr<   r   r   	greentestgevent.testingr   r   r   r   r	   version_infor   r   r   rL   mainrO   r;   r   <module>rV      s  & 


        ' ' ' ' ' ' 1 1 1 1 1 1 1 1 / / / / / / % % % % % % ! ! ! ! ! ! 
qQ  c c c c c( c c cL zIN r;   