forked from goodboy/tractor
1
0
Fork 0

Flip to using the `trio` spawner on windows

Was able to try it manually on a windows 10 system and the debugger
works great!
use_trio_on_win
Tyler Goodlet 2020-11-16 00:16:09 -05:00
parent 2d0e35b316
commit 4259738864
1 changed files with 3 additions and 4 deletions

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)