Skip to content

Commit

Permalink
TST: Use safer context for ProcessPoolExecutor (#8715)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic authored Jun 25, 2024
1 parent 5b2e2b4 commit 97dbdaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions distributed/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from distributed.metrics import time
from distributed.protocol import pickle
from distributed.scheduler import KilledWorker, Scheduler
from distributed.utils import wait_for
from distributed.utils import get_mp_context, wait_for
from distributed.utils_test import (
NO_AMM,
BlockedExecute,
Expand Down Expand Up @@ -2199,7 +2199,7 @@ async def test_bad_executor_annotation(c, s, a, b):

@gen_cluster(client=True)
async def test_process_executor(c, s, a, b):
with ProcessPoolExecutor() as e:
with ProcessPoolExecutor(mp_context=get_mp_context()) as e:
a.executors["processes"] = e
b.executors["processes"] = e

Expand Down Expand Up @@ -2231,7 +2231,7 @@ def kill_process():

@gen_cluster(nthreads=[("127.0.0.1", 1)], client=True)
async def test_process_executor_kills_process(c, s, a):
with ProcessPoolExecutor() as e:
with ProcessPoolExecutor(mp_context=get_mp_context()) as e:
a.executors["processes"] = e
with dask.annotate(executor="processes", retries=1):
future = c.submit(kill_process)
Expand All @@ -2254,7 +2254,7 @@ def raise_exc():

@gen_cluster(client=True)
async def test_process_executor_raise_exception(c, s, a, b):
with ProcessPoolExecutor() as e:
with ProcessPoolExecutor(mp_context=get_mp_context()) as e:
a.executors["processes"] = e
b.executors["processes"] = e
with dask.annotate(executor="processes", retries=1):
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_worker_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def test_custom_executor(c, s, a):
"""Don't try to acquire in-thread metrics when the executor is a ProcessPoolExecutor
or a custom, arbitrary executor.
"""
with ProcessPoolExecutor(1) as e:
with ProcessPoolExecutor(1, mp_context=distributed.utils.get_mp_context()) as e:
# Warm up executor - this can take up to 2s in Windows and MacOSX
e.submit(inc, 1).result()

Expand Down

0 comments on commit 97dbdaa

Please sign in to comment.