forked from goodboy/tractor
1
0
Fork 0

Run Windows on trio and mp backends

The new pure trio spawning backend uses `subprocess` internally which is
also supported on windows so let's run it in CI.
drop_cloudpickle
Tyler Goodlet 2020-07-25 12:00:04 -04:00
parent 7c3928f0bf
commit dddbeb0e71
4 changed files with 41 additions and 16 deletions

View File

@ -8,6 +8,17 @@ matrix:
os: windows
language: sh
python: 3.x # only works on linux
env: SPAWN_BACKEND="mp"
before_install:
- choco install python3 --params "/InstallDir:C:\\Python"
- export PATH="/c/Python:/c/Python/Scripts:$PATH"
- python -m pip install --upgrade pip wheel
- name: "Windows, Python Latest: trio"
os: windows
language: sh
python: 3.x # only works on linux
env: SPAWN_BACKEND="trio"
before_install:
- choco install python3 --params "/InstallDir:C:\\Python"
- export PATH="/c/Python:/c/Python/Scripts:$PATH"
@ -16,6 +27,17 @@ matrix:
- name: "Windows, Python 3.7: multiprocessing"
os: windows
python: 3.7 # only works on linux
env: SPAWN_BACKEND="mp"
language: sh
before_install:
- choco install python3 --version 3.7.4 --params "/InstallDir:C:\\Python"
- export PATH="/c/Python:/c/Python/Scripts:$PATH"
- python -m pip install --upgrade pip wheel
- name: "Windows, Python 3.7: trio"
os: windows
python: 3.7 # only works on linux
env: SPAWN_BACKEND="trio"
language: sh
before_install:
- choco install python3 --version 3.7.4 --params "/InstallDir:C:\\Python"

View File

@ -6,13 +6,21 @@ import platform
import pytest
import tractor
from tractor.testing import tractor_test
# export for tests
from tractor.testing import tractor_test # noqa
pytest_plugins = ['pytester']
_arb_addr = '127.0.0.1', random.randint(1000, 9999)
no_windows = pytest.mark.skipif(
platform.system() == "Windows",
reason="Test is unsupported on windows",
)
def pytest_addoption(parser):
parser.addoption(
"--ll", action="store", dest='loglevel',
@ -29,9 +37,6 @@ def pytest_addoption(parser):
def pytest_configure(config):
backend = config.option.spawn_backend
if platform.system() == "Windows":
backend = 'mp'
if backend == 'mp':
tractor._spawn.try_set_start_method('spawn')
elif backend == 'trio':
@ -68,10 +73,6 @@ def pytest_generate_tests(metafunc):
# incompatible with trio's global scheduler state
methods.remove('fork')
elif spawn_backend == 'trio':
if platform.system() == "Windows":
pytest.fail(
"Only `--spawn-backend=mp` is supported on Windows")
methods = ['trio']
metafunc.parametrize("start_method", methods, scope='module')

View File

@ -10,7 +10,7 @@ import pytest
import trio
import tractor
from conftest import tractor_test
from conftest import tractor_test, no_windows
async def assert_err(delay=0):
@ -339,6 +339,7 @@ async def test_nested_multierrors(loglevel, start_method):
subexc.type is trio.Cancelled)
@no_windows
def test_open_in_proc_cancel_via_SIGINT(loglevel, start_method):
"""Ensure that a control-C (SIGINT) signal cancels both the parent and
child processes in trionic fashion
@ -356,6 +357,7 @@ def test_open_in_proc_cancel_via_SIGINT(loglevel, start_method):
tractor.run(main)
@no_windows
def test_open_in_proc_cancel_via_SIGINT_other_task(
loglevel,
start_method

View File

@ -55,12 +55,13 @@ else:
def try_set_start_method(name: str) -> Optional[mp.context.BaseContext]:
"""Attempt to set the start method for process starting, aka the "actor
"""Attempt to set the method for process starting, aka the "actor
spawning backend".
If the desired method is not supported this function will error. On
Windows the only supported option is the ``multiprocessing`` "spawn"
method. The default on *nix systems is ``trio``.
If the desired method is not supported this function will error.
On Windows only the ``multiprocessing`` "spawn" method is offered
besides the default ``trio`` which uses async wrapping around
``subprocess.Popen``.
"""
global _ctx
global _spawn_method
@ -70,9 +71,8 @@ def try_set_start_method(name: str) -> Optional[mp.context.BaseContext]:
# forking is incompatible with ``trio``s global task tree
methods.remove('fork')
# no Windows support for trip yet
if platform.system() != 'Windows':
methods += ['trio']
# supported on all platforms
methods += ['trio']
if name not in methods:
raise ValueError(