Skip to content

Fix: Replace time.sleep polling in runtime_e2etest.py#204

Open
rwkeane wants to merge 1 commit intomainfrom
fix/runtime-e2e-polling-loops
Open

Fix: Replace time.sleep polling in runtime_e2etest.py#204
rwkeane wants to merge 1 commit intomainfrom
fix/runtime-e2e-polling-loops

Conversation

@rwkeane
Copy link
Owner

@rwkeane rwkeane commented Jun 21, 2025

Refactored multiple tests within tsercom/runtime_e2etest.py to replace time.sleep()-based polling loops with multiprocessing.Event-based synchronization. This enhances test determinism and reliability.

Tests and Runtimes affected:

  • test_out_of_process_torch_event_transport and StrDataTorchEventRuntime: Replaced data polling and a fixed sleep with events.
  • test_out_of_process_torch_data_torch_event_transport, test_out_of_process_torch_tensor_stress, and TorchDataTorchEventRuntime: Replaced polling for initial, event response (for the first test), and stopped data with events.
  • test_multiple_runtimes_out_of_process and test_client_type_runtime_in_process: Updated to use the already event-enabled FakeRuntime correctly with events, replacing polling loops.
  • test_event_broadcast_e2e and BroadcastTestFakeRuntime: Implemented per-listener events to synchronize broadcast data reception.

All changes include using a 'spawn' context for multiprocessing events and employing brief, bounded post-event polling loops to robustly handle IPC latencies before asserting on data in aggregators.

Refactored multiple tests within `tsercom/runtime_e2etest.py` to replace
`time.sleep()`-based polling loops with `multiprocessing.Event`-based
synchronization. This enhances test determinism and reliability.

Tests and Runtimes affected:
- `test_out_of_process_torch_event_transport` and `StrDataTorchEventRuntime`:
  Replaced data polling and a fixed sleep with events.
- `test_out_of_process_torch_data_torch_event_transport`,
  `test_out_of_process_torch_tensor_stress`, and `TorchDataTorchEventRuntime`:
  Replaced polling for initial, event response (for the first test), and
  stopped data with events.
- `test_multiple_runtimes_out_of_process` and `test_client_type_runtime_in_process`:
  Updated to use the already event-enabled `FakeRuntime` correctly with events,
  replacing polling loops.
- `test_event_broadcast_e2e` and `BroadcastTestFakeRuntime`:
  Implemented per-listener events to synchronize broadcast data reception.

All changes include using a 'spawn' context for multiprocessing events and
employing brief, bounded post-event polling loops to robustly handle IPC
latencies before asserting on data in aggregators.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant