
    i1                        d Z ddlZej        dd         dgk    rHddlZd Z	  ej        e                                           n# e$ r Y nw xY w ej        d           dS ddl	Z	ddl
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  G d dej                  Zedk    r ej                     dS dS )a  Test for GitHub issues 461 and 471.

When moving to Python 3, handling of KeyboardInterrupt exceptions caused
by a Ctrl-C raised an exception while printing the traceback for a
greenlet preventing the process from exiting. This test tests for proper
handling of KeyboardInterrupt.
    N   
subprocessc                      t           j                            d           t           j                                         t	          j        d           d S )Nzready
   )sysstdoutwriteflushgeventsleep     K/usr/local/lib/python3.11/dist-packages/gevent/tests/test__issues461_471.pytaskr      sB    
###
Rr   )PopenPIPE)CFFI_BACKEND)RUN_COVERAGE)WIN)PYPY3c                   N    e Zd Z ej        erepeoed          d             Z	dS )Testz;Interferes with the timing; times out waiting for the childc                 ,   t           rddlm} d|i}ni }t          t          j        t          dgfdt          i|}|j        	                                }t          |t                    s|                    d          }|                                }|                     |d           t           st          j        nt#          t          d          }|                    |           d	}t'          j                    }||d
z  z   }t'          j                    |z   }	t'          j                    |	k     rq|                                nt'          j                    |k    r|                    |           |	dz   }t'          j        d           t'          j                    |	k     q|                                 |                                 t1          d          |                     t           s|j        ndd           |j                                         d S )Nr   )CREATE_NEW_PROCESS_GROUPcreationflagsr   r   asciireadyCTRL_BREAK_EVENTg      9@g       @r   g?zFailed to wait for child)r   r   r   r   r   
executable__file__r   r   readline
isinstancestrdecodestripassertEqualsignalSIGINTgetattrsend_signaltimepollr   	terminatewaitAssertionError
returncodeclose)
selfr   kwargsplinesignal_to_sendwait_secondsnowmidtimeendtimes
             r   	test_hangzTest.test_hang(   s     ??????)+CDs~x>VVtVvVVA8$$&&DdC(( ,{{7++
 ::<<DT7+++ 36^V]]76K];^;^NMM.)))  L)++C\C/0GikkL0G)++''6688'9;;((MM.111%kG
3 )++'' $%?@@@ ;Q\\!Q???HNNr   N)
__name__
__module____qualname__unittestskipIfr   r   r   r   r;   r   r   r   r   r   &   sV        	*l>#I
K 
K1	 1	
K 
K1	 1	 1	r   r   __main__)__doc__r   argvr   r   spawngetKeyboardInterruptexitr'   r   r   r   r+   r?   gevent.testingtesting	greentestgevent.testing.sysinfor   r   r   r   TestCaser   r<   mainr   r   r   <module>rN      s    


8ABB<L>!!MMM  
T        CHQKKKKK MMM&&&&&&&&KKKOOO&&&&&&333333333333******,,,,,,6 6 6 6 6x  6 6 6p :	 s   "A AA