o
    oi1                     @   s   d Z ddlZejdd dgkr2ddlZdd Zz	ee  W n	 ey*   Y nw e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 dejZedkrwe  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                   C   s$   t jd t j  td d S )Nzready
   )sysstdoutwriteflushgeventsleep r   r   _/var/www/html/pca-backend/venv/lib/python3.10/site-packages/gevent/tests/test__issues461_471.pytask   s   
r   )PopenPIPE)CFFI_BACKEND)RUN_COVERAGE)WIN)PYPY3c                   @   s,   e Zd Zeer
epeoeddd Z	dS )Testz;Interferes with the timing; times out waiting for the childc           
      C   s8  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 }||d
  }t | }	t |	k r~| d urdn&t |krs|| |	d }td t |	k s]|  |  t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endtimer   r   r   	test_hang(   s:   






	zTest.test_hangN)
__name__
__module____qualname__unittestskipIfr   r   r   r   r6   r   r   r   r   r   &   s    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   r7   mainr   r   r   r   <module>   s0    8