forked from goodboy/tractor
Test cancel with SIGINT on non-windows as well
parent
cd2d8c217a
commit
0d9483376d
|
@ -1,6 +1,10 @@
|
||||||
"""
|
"""
|
||||||
Actor "discovery" testing
|
Actor "discovery" testing
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
import platform
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import tractor
|
import tractor
|
||||||
import trio
|
import trio
|
||||||
|
@ -82,7 +86,8 @@ async def test_trynamic_trio(func, start_method):
|
||||||
print("CUTTTT CUUTT CUT!!?! Donny!! You're supposed to say...")
|
print("CUTTTT CUUTT CUT!!?! Donny!! You're supposed to say...")
|
||||||
|
|
||||||
|
|
||||||
def test_subactors_unregister_on_cancel(start_method):
|
@pytest.mark.parametrize('use_signal', [False, True])
|
||||||
|
def test_subactors_unregister_on_cancel(start_method, use_signal):
|
||||||
"""Verify that cancelling a nursery results in all subactors
|
"""Verify that cancelling a nursery results in all subactors
|
||||||
deregistering themselves with the arbiter.
|
deregistering themselves with the arbiter.
|
||||||
"""
|
"""
|
||||||
|
@ -110,8 +115,12 @@ def test_subactors_unregister_on_cancel(start_method):
|
||||||
assert len(portals) + 1 == len(registry)
|
assert len(portals) + 1 == len(registry)
|
||||||
|
|
||||||
# trigger cancel
|
# trigger cancel
|
||||||
|
if use_signal:
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
pytest.skip("SIGINT not supported on windows")
|
||||||
|
os.kill(os.getpid(), signal.SIGINT)
|
||||||
|
else:
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# all subactors should have de-registered
|
# all subactors should have de-registered
|
||||||
await trio.sleep(0.5)
|
await trio.sleep(0.5)
|
||||||
|
|
Loading…
Reference in New Issue