← back to Exo
Resolve test event ordering flakiness (#1194)
618cee5223bd9299d26486cb5e36e5d9d3ae4c88 · 2026-01-18 20:33:20 +0000 · rltakashige
## Motivation
mp sender occasionally does not have time to flush its events before
collect() is called, making the event ordering test fail.
## Changes
- Replace mp_channel with simple collector for event ordering test
- Also suppress warning for <frozen importlib._bootstrap>:488 <frozen
importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject
has no __module__ attribute
## Why It Works
<!-- Explain why your approach solves the problem -->
## Test Plan
### Manual Testing
<!-- Hardware: (e.g., MacBook Pro M1 Max 32GB, Mac Mini M2 16GB,
connected via Thunderbolt 4) -->
<!-- What you did: -->
<!-- - -->
### Automated Testing
Ran the test 100 times without it failing.
Files touched
M pyproject.tomlM src/exo/worker/tests/unittests/test_runner/test_event_ordering.py
Diff
commit 618cee5223bd9299d26486cb5e36e5d9d3ae4c88
Author: rltakashige <rl.takashige@gmail.com>
Date: Sun Jan 18 20:33:20 2026 +0000
Resolve test event ordering flakiness (#1194)
## Motivation
mp sender occasionally does not have time to flush its events before
collect() is called, making the event ordering test fail.
## Changes
- Replace mp_channel with simple collector for event ordering test
- Also suppress warning for <frozen importlib._bootstrap>:488 <frozen
importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject
has no __module__ attribute
## Why It Works
<!-- Explain why your approach solves the problem -->
## Test Plan
### Manual Testing
<!-- Hardware: (e.g., MacBook Pro M1 Max 32GB, Mac Mini M2 16GB,
connected via Thunderbolt 4) -->
<!-- What you did: -->
<!-- - -->
### Automated Testing
Ran the test 100 times without it failing.
---
pyproject.toml | 3 +++
.../unittests/test_runner/test_event_ordering.py | 25 ++++++++++++++++------
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 9cdc3220..5f4fa7ea 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -126,3 +126,6 @@ env = [
"EXO_TESTS=1"
]
addopts = "-m 'not slow'"
+filterwarnings = [
+ "ignore:builtin type Swig:DeprecationWarning",
+]
diff --git a/src/exo/worker/tests/unittests/test_runner/test_event_ordering.py b/src/exo/worker/tests/unittests/test_runner/test_event_ordering.py
index e1744d1b..a8b4b1a5 100644
--- a/src/exo/worker/tests/unittests/test_runner/test_event_ordering.py
+++ b/src/exo/worker/tests/unittests/test_runner/test_event_ordering.py
@@ -121,6 +121,21 @@ def patch_out_mlx(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(mlx_runner, "mlx_generate", fake_generate)
+# Use a fake event_sender to remove test flakiness.
+class EventCollector:
+ def __init__(self) -> None:
+ self.events: list[Event] = []
+
+ def send(self, event: Event) -> None:
+ self.events.append(event)
+
+ def close(self) -> None:
+ pass
+
+ def join(self) -> None:
+ pass
+
+
def _run(tasks: Iterable[Task]):
bound_instance = get_bound_mlx_ring_instance(
instance_id=INSTANCE_1_ID,
@@ -130,22 +145,20 @@ def _run(tasks: Iterable[Task]):
)
task_sender, task_receiver = mp_channel[Task]()
- event_sender, event_receiver = mp_channel[Event]()
+ event_sender = EventCollector()
- with task_sender, event_receiver:
+ with task_sender:
for t in tasks:
task_sender.send(t)
# worst monkeypatch known to man
# this is some c++ nonsense
- event_sender.close = nothin
- event_sender.join = nothin
task_receiver.close = nothin
task_receiver.join = nothin
- mlx_runner.main(bound_instance, event_sender, task_receiver)
+ mlx_runner.main(bound_instance, event_sender, task_receiver) # type: ignore[arg-type]
- return event_receiver.collect()
+ return event_sender.events
def test_events_processed_in_correct_order(patch_out_mlx: pytest.MonkeyPatch):
← 9c29eb7d Add proxy and custom SSL certificate support for corporate
·
back to Exo
·
re-raise exceptions in the runner (#1198) d19bf024 →