📁 File Manager Pro
v10.0.3 | PHP: 8.2.31
Server: LiteSpeed
2026-06-28 06:55:35
📂
/ (Root)
/
opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
greenlet
/
tests
/
__pycache__
📍 /opt/hc_python/lib/python3.12/site-packages/greenlet/tests/__pycache__
🔄 Refresh
✏️
Editing: test_interpreter_shutdown.cpython-312.pyc
Read Only
� }�*j)� � �x � d Z ddlZddlZddlZddlZddlmZ G d� de� Zedk( r ej � yy)u: Tests for greenlet behavior during interpreter shutdown (Py_FinalizeEx). These tests are organized into four groups: A. Core safety (smoke): no crashes with active greenlets at shutdown. B. Cleanup semantics: GreenletExit / finally still works during normal thread exit (the standard production path). C. Atexit "still works" tests: getcurrent() / greenlet construction during atexit handlers registered AFTER greenlet import (i.e. BEFORE greenlet's cleanup handler in LIFO order) must return valid objects — verifies the guards don't over-block. D. TDD-certified regression tests: getcurrent() must return None when called AFTER greenlet's cleanup (GC finalization phase or late atexit phase). These tests fail on greenlet 3.3.2 and pass with the fix across Python 3.10-3.14. � N)�TestCasec � � e Zd Zd� Zd� Zd� Zd� Zd� Zd� Zd� Z d� Z d � Zd � Zd� Z d� Zd � Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zy)�TestInterpreterShutdownc �� � t j |� }t j t j d|gdddd�� }|j |j |j fS )z� Run a Python script in a subprocess that exercises greenlet during interpreter shutdown. Returns (returncode, stdout, stderr). z-cT� F)�capture_output�text�timeout�check) �textwrap�dedent� subprocess�run�sys� executable� returncode�stdout�stderr)�self�script_body�full_script�results �Y/opt/hc_python/lib64/python3.12/site-packages/greenlet/tests/test_interpreter_shutdown.py�_run_shutdown_scriptz,TestInterpreterShutdown._run_shutdown_script sW � � �o�o�k�2����� �^�^�T�;�/����� �� � � �&�-�-����>�>� c � � | j d� \ }}}| j |dd|� d|� |� �� | j d|� y )NaT import greenlet def worker(): greenlet.getcurrent().parent.switch("from worker") return "done" g = greenlet.greenlet(worker) result = g.switch() assert result == "from worker", result print("OK: exiting with active greenlet") r �Process crashed (rc=�): z OK: exiting with active greenlet�r �assertEqual�assertIn�r �rcr r s r �)test_active_greenlet_at_shutdown_no_crashzATestInterpreterShutdown.test_active_greenlet_at_shutdown_no_crash0 sU � � "�6�6� 8� ���F�F� ����Q�"6�r�d�$�v�h�v�h� O�P�� � �8�&�Ar c � � | j d� \ }}}| j |dd|� d|� |� �� | j d|� y )Na� import greenlet def worker(name): greenlet.getcurrent().parent.switch(f"hello from {name}") return "done" greenlets = [] for i in range(10): g = greenlet.greenlet(worker) result = g.switch(f"g{i}") greenlets.append(g) print(f"OK: {len(greenlets)} active greenlets at shutdown") r r r z#OK: 10 active greenlets at shutdownr r"