
    <|h1                     ~   d Z ddlZej                  dd dgk(  r;ddlZd Z	  ej
                  e      j                           ej                  d       y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j4                          yy# e$ r Y yw xY w)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                  j                  d       t         j                  j                          t	        j
                  d       y )Nzready
   )sysstdoutwriteflushgeventsleep     _/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/tests/test__issues461_471.pytaskr      s0    

#

Rr   )PopenPIPE)CFFI_BACKEND)RUN_COVERAGE)WIN)PYPY3c                   V    e Zd Z ej                  exr exs exr ed      d        Z	y)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                  j                         }t        |t              s|j                  d      }|j                         }| j                  |d       t         st        j                   nt#        t        d      }|j%                  |       d	}t'        j&                         }||d
z  z   }t'        j&                         |z   }	t'        j&                         |	k  rk|j)                         nt'        j&                         |kD  r|j%                  |       |	dz   }t'        j*                  d       t'        j&                         |	k  rk|j-                          |j/                          t1        d      | j                  t         s|j2                  ndd       |j                  j5                          y )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(   sw    ?)+CDs~~x>VtVvVA88$$&DdC({{7+
 ::<DT7+ 36V]]76K];^NMM.)  L))+C\C/0GiikL0G))+'668'99;(MM.1%kG

3 ))+' $%?@@ Q\\!Q?HHNNr   N)
__name__
__module____qualname__unittestskipIfr   r   r   r   r;   r   r   r   r   r   &   s5    	*l>#I
K1	
K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    88AB<L>!
T  CHHQK &&33*,6x   6p :	 S  s    B4 4B<;B<