o
    ¨ÝjÉ  ã                   @   sd   d Z ddlZddlZddlZddlZejddd� dd„ Ze eƒ ¡ e ¡  e	dƒ e 
d¡ dS )	a¶  Out-of-process payload for the free-threaded switch/critical-section deadlock.

See ``freethread_switch_deadlock.py`` in the repo root for the full write-up.
Before the fix, a greenlet switch swapped C stacks but left any held
``PyCriticalSection`` locks (tracked in ``tstate->critical_section``) locked.
asyncio's ``Task.__step`` holds such a lock on the running task across the step,
so switching into a child greenlet and touching that task from there blocked
forever. A fixed build (and any GIL-enabled build) prints the sentinel; a
regressed free-threaded build deadlocks, and the watchdog turns that hang into a
non-zero exit so the test fails loudly instead of stalling the whole suite.
é    Né   T)Úexitc                  ƒ   s(   �t  ¡ ‰ ‡ fdd„} t | ¡ ¡  d S )Nc                      s    ˆ   dd„ ¡ ˆ  dd„ ¡ d S )Nc                 S   ó   d S ©N© ©Ú_r   r   úf/var/www/html/chatgpt/venv/lib/python3.10/site-packages/greenlet/tests/fail_switch_critical_section.pyÚ<lambda>   ó    z.main.<locals>.in_child_fiber.<locals>.<lambda>c                 S   r   r   r   r   r   r   r	   r
      r   )Zadd_done_callbackZremove_done_callbackr   ©Útaskr   r	   Úin_child_fiber   s   zmain.<locals>.in_child_fiber)ÚasyncioZcurrent_taskÚgreenletÚswitch)r   r   r   r	   Úmain   s   €r   zSWITCH CS OK)Ú__doc__r   ÚfaulthandlerÚsysr   Zdump_traceback_laterr   ÚrunZcancel_dump_traceback_laterÚprintr   r   r   r   r	   Ú<module>   s    