|
1 | 1 | import asyncio |
2 | | -import os |
| 2 | +import platform |
3 | 3 | import sys |
4 | 4 | import time |
5 | 5 |
|
|
17 | 17 | with_ipyparallel, |
18 | 18 | ) |
19 | 19 |
|
| 20 | +OPERATING_SYSTEM = platform.system() |
| 21 | + |
20 | 22 |
|
21 | 23 | def blocking_runner(learner, goal): |
22 | 24 | BlockingRunner(learner, goal, executor=SequentialExecutor()) |
@@ -71,22 +73,6 @@ async def f(x): |
71 | 73 | # --- Test with different executors |
72 | 74 |
|
73 | 75 |
|
74 | | -@pytest.fixture(scope="session") |
75 | | -def ipyparallel_executor(): |
76 | | - from ipyparallel import Client |
77 | | - |
78 | | - if os.name == "nt": |
79 | | - import wexpect as expect |
80 | | - else: |
81 | | - import pexpect as expect |
82 | | - |
83 | | - child = expect.spawn("ipcluster start -n 1") |
84 | | - child.expect("Engines appear to have started successfully", timeout=35) |
85 | | - yield Client() |
86 | | - if not child.terminate(force=True): |
87 | | - raise RuntimeError("Could not stop ipcluster") |
88 | | - |
89 | | - |
90 | 76 | @pytest.fixture(scope="session") |
91 | 77 | def loky_executor(): |
92 | 78 | import loky |
@@ -117,17 +103,35 @@ def test_stop_after_goal(): |
117 | 103 |
|
118 | 104 |
|
119 | 105 | @pytest.mark.skipif(not with_ipyparallel, reason="IPyparallel is not installed") |
120 | | -def test_ipyparallel_executor(ipyparallel_executor): |
| 106 | +@pytest.mark.skipif( |
| 107 | + OPERATING_SYSTEM == "Windows" and sys.version_info >= (3, 7), |
| 108 | + reason="Gets stuck in CI", |
| 109 | +) |
| 110 | +def test_ipyparallel_executor(): |
| 111 | + from ipyparallel import Client |
| 112 | + |
| 113 | + if OPERATING_SYSTEM == "Windows": |
| 114 | + import wexpect as expect |
| 115 | + else: |
| 116 | + import pexpect as expect |
| 117 | + |
| 118 | + child = expect.spawn("ipcluster start -n 1") |
| 119 | + child.expect("Engines appear to have started successfully", timeout=35) |
| 120 | + ipyparallel_executor = Client() |
121 | 121 | learner = Learner1D(linear, (-1, 1)) |
122 | 122 | BlockingRunner(learner, trivial_goal, executor=ipyparallel_executor) |
| 123 | + |
123 | 124 | assert learner.npoints > 0 |
124 | 125 |
|
| 126 | + if not child.terminate(force=True): |
| 127 | + raise RuntimeError("Could not stop ipcluster") |
| 128 | + |
125 | 129 |
|
126 | 130 | @flaky.flaky(max_runs=5) |
127 | 131 | @pytest.mark.timeout(60) |
128 | 132 | @pytest.mark.skipif(not with_distributed, reason="dask.distributed is not installed") |
129 | | -@pytest.mark.skipif(os.name == "nt", reason="XXX: seems to always fail") |
130 | | -@pytest.mark.skipif(sys.platform == "darwin", reason="XXX: intermittently fails") |
| 133 | +@pytest.mark.skipif(OPERATING_SYSTEM == "Windows", reason="XXX: seems to always fail") |
| 134 | +@pytest.mark.skipif(OPERATING_SYSTEM == "Darwin", reason="XXX: intermittently fails") |
131 | 135 | def test_distributed_executor(): |
132 | 136 | from distributed import Client |
133 | 137 |
|
|
0 commit comments