@@ -40,7 +40,7 @@ def _get_dashboard_port(client: Client) -> int:
4040
4141
4242def test_defaults (loop , requires_default_ports ):
43- with popen (["dask" , "scheduler" ]):
43+ with popen ([sys . executable , "-m" , "dask" , "scheduler" ]):
4444
4545 async def f ():
4646 # Default behaviour is to listen on all addresses
@@ -53,7 +53,17 @@ async def f():
5353
5454def test_hostport (loop ):
5555 port = open_port ()
56- with popen (["dask" , "scheduler" , "--no-dashboard" , "--host" , f"127.0.0.1:{ port } " ]):
56+ with popen (
57+ [
58+ sys .executable ,
59+ "-m" ,
60+ "dask" ,
61+ "scheduler" ,
62+ "--no-dashboard" ,
63+ "--host" ,
64+ f"127.0.0.1:{ port } " ,
65+ ]
66+ ):
5767
5868 async def f ():
5969 # The scheduler's main port can't be contacted from the outside
@@ -65,7 +75,7 @@ async def f():
6575
6676
6777def test_no_dashboard (loop , requires_default_ports ):
68- with popen (["dask" , "scheduler" , "--no-dashboard" ]):
78+ with popen ([sys . executable , "-m" , "dask" , "scheduler" , "--no-dashboard" ]):
6979 with Client (f"127.0.0.1:{ Scheduler .default_port } " , loop = loop ):
7080 response = requests .get ("http://127.0.0.1:8787/status/" )
7181 assert response .status_code == 404
@@ -76,7 +86,7 @@ def test_dashboard(loop):
7686 port = open_port ()
7787
7888 with popen (
79- ["dask" , "scheduler" , "--host" , f"127.0.0.1:{ port } " ],
89+ [sys . executable , "-m" , "dask" , "scheduler" , "--host" , f"127.0.0.1:{ port } " ],
8090 ):
8191 with Client (f"127.0.0.1:{ port } " , loop = loop ) as c :
8292 dashboard_port = _get_dashboard_port (c )
@@ -109,6 +119,8 @@ def test_dashboard_non_standard_ports(loop):
109119 port2 = open_port ()
110120 with popen (
111121 [
122+ sys .executable ,
123+ "-m" ,
112124 "dask" ,
113125 "scheduler" ,
114126 f"--port={ port1 } " ,
@@ -137,6 +149,8 @@ def test_multiple_protocols(loop):
137149 port2 = open_port ()
138150 with popen (
139151 [
152+ sys .executable ,
153+ "-m" ,
140154 "dask" ,
141155 "scheduler" ,
142156 "--protocol=tcp,ws" ,
@@ -158,6 +172,8 @@ def test_dashboard_allowlist(loop):
158172 port = open_port ()
159173 with popen (
160174 [
175+ sys .executable ,
176+ "-m" ,
161177 "dask" ,
162178 "scheduler" ,
163179 f"--port={ port } " ,
@@ -198,6 +214,8 @@ def test_interface(loop):
198214 port = open_port ()
199215 with popen (
200216 [
217+ sys .executable ,
218+ "-m" ,
201219 "dask" ,
202220 "scheduler" ,
203221 f"--port={ port } " ,
@@ -208,6 +226,8 @@ def test_interface(loop):
208226 ) as s :
209227 with popen (
210228 [
229+ sys .executable ,
230+ "-m" ,
211231 "dask" ,
212232 "worker" ,
213233 f"127.0.0.1:{ port } " ,
@@ -252,12 +272,24 @@ def check_pidfile(proc, pidfile):
252272 assert proc .pid == pid
253273
254274 with tmpfile () as s :
255- with popen (["dask" , "scheduler" , "--pid-file" , s , "--no-dashboard" ]) as sched :
275+ with popen (
276+ [
277+ sys .executable ,
278+ "-m" ,
279+ "dask" ,
280+ "scheduler" ,
281+ "--pid-file" ,
282+ s ,
283+ "--no-dashboard" ,
284+ ]
285+ ) as sched :
256286 check_pidfile (sched , s )
257287
258288 with tmpfile () as w :
259289 with popen (
260290 [
291+ sys .executable ,
292+ "-m" ,
261293 "dask" ,
262294 "worker" ,
263295 f"127.0.0.1:{ port } " ,
@@ -273,6 +305,8 @@ def test_scheduler_port_zero(loop):
273305 with tmpfile () as fn :
274306 with popen (
275307 [
308+ sys .executable ,
309+ "-m" ,
276310 "dask" ,
277311 "scheduler" ,
278312 "--no-dashboard" ,
@@ -292,6 +326,8 @@ def test_dashboard_port_zero(loop):
292326 port = open_port ()
293327 with popen (
294328 [
329+ sys .executable ,
330+ "-m" ,
295331 "dask" ,
296332 "scheduler" ,
297333 "--host" ,
@@ -329,6 +365,8 @@ def check_scheduler():
329365 with tmpfile () as fn :
330366 with popen (
331367 [
368+ sys .executable ,
369+ "-m" ,
332370 "dask" ,
333371 "scheduler" ,
334372 "--scheduler-file" ,
@@ -359,6 +397,8 @@ def check_scheduler():
359397 with tmpfile () as fn :
360398 with popen (
361399 [
400+ sys .executable ,
401+ "-m" ,
362402 "dask" ,
363403 "scheduler" ,
364404 "--scheduler-file" ,
@@ -382,6 +422,8 @@ def test_preload_remote_module(loop, tmp_path):
382422 ):
383423 with popen (
384424 [
425+ sys .executable ,
426+ "-m" ,
385427 "dask" ,
386428 "scheduler" ,
387429 "--scheduler-file" ,
@@ -408,7 +450,9 @@ def test_preload_config(loop):
408450 with tmpfile () as fn :
409451 env = os .environ .copy ()
410452 env ["DASK_DISTRIBUTED__SCHEDULER__PRELOAD" ] = PRELOAD_TEXT
411- with popen (["dask" , "scheduler" , "--scheduler-file" , fn ], env = env ):
453+ with popen (
454+ [sys .executable , "-m" , "dask" , "scheduler" , "--scheduler-file" , fn ], env = env
455+ ):
412456 with Client (scheduler_file = fn , loop = loop ) as c :
413457 assert (
414458 c .run_on_scheduler (lambda dask_scheduler : dask_scheduler .foo )
@@ -446,6 +490,8 @@ def check_passthrough():
446490 print (fn )
447491 with popen (
448492 [
493+ sys .executable ,
494+ "-m" ,
449495 "dask" ,
450496 "scheduler" ,
451497 "--scheduler-file" ,
@@ -477,7 +523,16 @@ def check_passthrough():
477523 with tmpfile () as fn2 :
478524 print (fn2 )
479525 with popen (
480- ["dask" , "scheduler" , "--scheduler-file" , fn2 , "--preload" , path ],
526+ [
527+ sys .executable ,
528+ "-m" ,
529+ "dask" ,
530+ "scheduler" ,
531+ "--scheduler-file" ,
532+ fn2 ,
533+ "--preload" ,
534+ path ,
535+ ],
481536 stdout = sys .stdout ,
482537 stderr = sys .stderr ,
483538 ):
@@ -530,10 +585,20 @@ def dask_setup(worker):
530585"""
531586 port = open_port ()
532587 with popen (
533- ["dask" , "scheduler" , "--no-dashboard" , "--host" , f"127.0.0.1:{ port } " ]
588+ [
589+ sys .executable ,
590+ "-m" ,
591+ "dask" ,
592+ "scheduler" ,
593+ "--no-dashboard" ,
594+ "--host" ,
595+ f"127.0.0.1:{ port } " ,
596+ ]
534597 ) as s :
535598 with popen (
536599 [
600+ sys .executable ,
601+ "-m" ,
537602 "dask" ,
538603 "worker" ,
539604 f"localhost:{ port } " ,
@@ -555,9 +620,37 @@ def dask_setup(worker):
555620def test_multiple_workers (loop ):
556621 scheduler_address = f"127.0.0.1:{ open_port ()} "
557622 with (
558- popen (["dask" , "scheduler" , "--no-dashboard" , "--host" , scheduler_address ]),
559- popen (["dask" , "worker" , scheduler_address , "--no-dashboard" ]),
560- popen (["dask" , "worker" , scheduler_address , "--no-dashboard" ]),
623+ popen (
624+ [
625+ sys .executable ,
626+ "-m" ,
627+ "dask" ,
628+ "scheduler" ,
629+ "--no-dashboard" ,
630+ "--host" ,
631+ scheduler_address ,
632+ ]
633+ ),
634+ popen (
635+ [
636+ sys .executable ,
637+ "-m" ,
638+ "dask" ,
639+ "worker" ,
640+ scheduler_address ,
641+ "--no-dashboard" ,
642+ ]
643+ ),
644+ popen (
645+ [
646+ sys .executable ,
647+ "-m" ,
648+ "dask" ,
649+ "worker" ,
650+ scheduler_address ,
651+ "--no-dashboard" ,
652+ ]
653+ ),
561654 Client (scheduler_address , loop = loop ) as c ,
562655 ):
563656 start = time ()
0 commit comments