|
1 | | -import _thread |
| 1 | +import concurrent.futures |
2 | 2 | import json |
3 | 3 | import os |
4 | 4 | import pathlib |
@@ -172,23 +172,6 @@ def test_sort_alias(self): |
172 | 172 | Extract(DUMMY_SPAN, Var(DUMMY_SPAN, "my_map2"), Lit(DUMMY_SPAN, Int(0))), |
173 | 173 | ) |
174 | 174 |
|
175 | | - extract_report = egraph.extract_report() |
176 | | - assert isinstance(extract_report, Best) |
177 | | - assert extract_report.termdag.term_to_expr(extract_report.term, DUMMY_SPAN) == Call( |
178 | | - DUMMY_SPAN, |
179 | | - "map-insert", |
180 | | - [ |
181 | | - Call( |
182 | | - DUMMY_SPAN, |
183 | | - "map-insert", |
184 | | - [Call(DUMMY_SPAN, "map-empty", []), Lit(DUMMY_SPAN, Int(2)), Lit(DUMMY_SPAN, String("two"))], |
185 | | - ), |
186 | | - Lit(DUMMY_SPAN, Int(1)), |
187 | | - Lit(DUMMY_SPAN, String("one")), |
188 | | - ], |
189 | | - ) |
190 | | - assert extract_report.cost == 4 |
191 | | - |
192 | 175 |
|
193 | 176 | class TestVariant: |
194 | 177 | def test_repr(self): |
@@ -228,16 +211,18 @@ def test_cmds(self): |
228 | 211 | ), |
229 | 212 | RunSchedule(Repeat(DUMMY_SPAN, 10, Run(DUMMY_SPAN, RunConfig("")))), |
230 | 213 | ) |
231 | | - |
232 | | - _thread.start_new_thread(print, cmds) |
| 214 | + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: |
| 215 | + executor.submit(print, cmds).result() |
233 | 216 |
|
234 | 217 | @pytest.mark.xfail(reason="egraphs are unsendable") |
235 | 218 | def test_egraph(self): |
236 | | - _thread.start_new_thread( |
237 | | - EGraph().run_program, (Datatype(DUMMY_SPAN, "Math", [Variant(DUMMY_SPAN, "Add", ["Math", "Math"])]),) |
238 | | - ) |
| 219 | + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: |
| 220 | + executor.submit( |
| 221 | + EGraph().run_program, Datatype(DUMMY_SPAN, "Math", [Variant(DUMMY_SPAN, "Add", ["Math", "Math"])]) |
| 222 | + ).result() |
239 | 223 |
|
240 | 224 | def test_serialized_egraph(self): |
241 | 225 | egraph = EGraph() |
242 | 226 | serialized = egraph.serialize([]) |
243 | | - _thread.start_new_thread(print, (serialized,)) |
| 227 | + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: |
| 228 | + executor.submit(print, (serialized,)).result() |
0 commit comments