Merge pull request #166 from goodboy/use_trio_on_win

Flip to using the `trio` spawner on windows
logo_tweaks
goodboy 2021-09-18 16:04:12 -04:00 committed by GitHub
commit a868196d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Switch to using the ``trio`` process spawner by default on windows.
This gets windows users debugger support (manually tested) and in
general a more resilient (nested) actor tree implementation.

View File

@ -24,7 +24,7 @@ with open('docs/README.rst', encoding='utf-8') as f:
setup( setup(
name="tractor", name="tractor",
version='0.1.0a2', # alpha zone version='0.1.0a3.dev0', # alpha zone
description='structured concurrrent "actors"', description='structured concurrrent "actors"',
long_description=readme, long_description=readme,
license='GPLv3', license='GPLv3',

View File

@ -38,18 +38,17 @@ log = get_logger('tractor')
# placeholder for an mp start context if so using that backend # placeholder for an mp start context if so using that backend
_ctx: Optional[mp.context.BaseContext] = None _ctx: Optional[mp.context.BaseContext] = None
_spawn_method: str = "spawn" _spawn_method: str = "trio"
if platform.system() == 'Windows': if platform.system() == 'Windows':
_spawn_method = "spawn"
_ctx = mp.get_context("spawn") _ctx = mp.get_context("spawn")
async def proc_waiter(proc: mp.Process) -> None: async def proc_waiter(proc: mp.Process) -> None:
await trio.lowlevel.WaitForSingleObject(proc.sentinel) await trio.lowlevel.WaitForSingleObject(proc.sentinel)
else: else:
# *NIX systems use ``trio`` primitives as our default # *NIX systems use ``trio`` primitives as our default as well
_spawn_method = "trio"
async def proc_waiter(proc: mp.Process) -> None: async def proc_waiter(proc: mp.Process) -> None:
await trio.lowlevel.wait_readable(proc.sentinel) await trio.lowlevel.wait_readable(proc.sentinel)