Skip to content

[error-handling] Infinite while True loops without timeout #25

@wody34

Description

@wody34

📁 Location

  • Files: tests/test_nest_MPI_threading/*.py (3 files)
  • Category: error-handling
  • Severity: high
  • Hashes: 4149d9fe3929, 3c8fe0ea688c, 0330af459e7e

🔍 Problem

MPI communication loops use while True: without timeout protection. If communication fails, these loops block forever.

Affected Files

  1. record_region_activity_multiple.py:43
  2. input_region_activity_multiple.py:47
  3. input_current_region_activity_multiple.py:47

💡 Fix

# Before
while True:
    comm.Recv(...)
    # process

# After
import time
start_time = time.time()
TIMEOUT_SECONDS = 300  # 5 minutes

while time.time() - start_time < TIMEOUT_SECONDS:
    comm.Recv(...)
    # process
else:
    raise TimeoutError(f"MPI communication timeout after {TIMEOUT_SECONDS}s")

🧪 TDD Evidence

Test file: tests/evidence/test_nest_mpi_races.py

  • test_infinite_loop_timeout_pattern demonstrates proper timeout handling
tests/evidence/test_nest_mpi_races.py::TestNestMpiRaceConditions::test_infinite_loop_timeout_pattern PASSED

Run: 2026-02-05-1228 | Auto-generated by UltraQA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions