PATH:
opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
greenlet
/
tests
""" Uses a trace function to switch greenlets at unexpected times. In the trace function, we switch from the current greenlet to another greenlet, which switches """ import greenlet g1 = None g2 = None switch_to_g2 = False def tracefunc(*args): print('TRACE', *args) global switch_to_g2 if switch_to_g2: switch_to_g2 = False g2.switch() print('\tLEAVE TRACE', *args) def g1_run(): print('In g1_run') global switch_to_g2 switch_to_g2 = True from_parent = greenlet.getcurrent().parent.switch() print('Return to g1_run') print('From parent', from_parent) def g2_run(): #g1.switch() greenlet.getcurrent().parent.switch() greenlet.settrace(tracefunc) g1 = greenlet.greenlet(g1_run) g2 = greenlet.greenlet(g2_run) # This switch didn't actually finish! # And if it did, it would raise TypeError # because g1_run() doesn't take any arguments. g1.switch(1) print('Back in main') g1.switch(2)
[-] fail_clearing_run_switches.py
[edit]
[+]
__pycache__
[-] fail_switch_two_greenlets.py
[edit]
[-] fail_slp_switch.py
[edit]
[-] _test_extension.cpython-312-x86_64-linux-gnu.so
[edit]
[-] test_generator.py
[edit]
[-] test_extension_interface.py
[edit]
[-] test_greenlet.py
[edit]
[-] test_tracing.py
[edit]
[-] _test_extension_cpp.cpp
[edit]
[-] __init__.py
[edit]
[-] test_throw.py
[edit]
[-] test_version.py
[edit]
[-] test_greenlet_trash.py
[edit]
[-] test_gc.py
[edit]
[+]
..
[-] _test_extension.c
[edit]
[-] test_stack_saved.py
[edit]
[-] test_cpp.py
[edit]
[-] test_weakref.py
[edit]
[-] fail_switch_three_greenlets2.py
[edit]
[-] fail_initialstub_already_started.py
[edit]
[-] leakcheck.py
[edit]
[-] fail_cpp_exception.py
[edit]
[-] test_contextvars.py
[edit]
[-] _test_extension_cpp.cpython-312-x86_64-linux-gnu.so
[edit]
[-] test_leaks.py
[edit]
[-] test_generator_nested.py
[edit]
[-] fail_switch_three_greenlets.py
[edit]