Summary
Test wheels building / Build wheels for macos-arm on macos-14 failed on pp311-macosx_arm64 with a Twisted unit test race.
Failing run/job:
https://github.com/scylladb/python-driver/actions/runs/28405982626/job/84168473960?pr=895
Failure
Failed test:
tests/unit/io/test_twistedreactor.py::TestTwistedConnection::test_connection_initialization
Assertion failure:
Expected: run(installSignalHandlers=False)
Actual: not called.
The test creates a TwistedConnection, which calls TwistedLoop.maybe_start(). maybe_start() starts the reactor on a background thread:
self._thread = Thread(target=reactor.run, kwargs={'installSignalHandlers': False})
self._thread.start()
The test immediately asserts that mocked reactor.run was called. Thread.start() can return before the target function runs, so on slower/different scheduling, especially PyPy on macOS arm, the assertion can run first.
Notes
This appears flaky rather than caused by PR #895. The PR only removed an unused import from tests/unit/io/test_twistedreactor.py; it did not change Twisted reactor behavior.
In the same macOS arm job, CPython 3.10 through 3.14 passed. The failure occurred only on PyPy 3.11.
Possible fixes
- Wait/poll for the mocked
reactor.run call before asserting.
- Or avoid asserting immediate background-thread execution; mock
Thread and assert target/kwargs/start behavior instead.
- Ensure teardown does not leave reactor/thread state that can affect later tests.
Summary
Test wheels building / Build wheels for macos-arm on macos-14failed onpp311-macosx_arm64with a Twisted unit test race.Failing run/job:
https://github.com/scylladb/python-driver/actions/runs/28405982626/job/84168473960?pr=895
Failure
Failed test:
Assertion failure:
The test creates a
TwistedConnection, which callsTwistedLoop.maybe_start().maybe_start()starts the reactor on a background thread:The test immediately asserts that mocked
reactor.runwas called.Thread.start()can return before the target function runs, so on slower/different scheduling, especially PyPy on macOS arm, the assertion can run first.Notes
This appears flaky rather than caused by PR #895. The PR only removed an unused import from
tests/unit/io/test_twistedreactor.py; it did not change Twisted reactor behavior.In the same macOS arm job, CPython 3.10 through 3.14 passed. The failure occurred only on PyPy 3.11.
Possible fixes
reactor.runcall before asserting.Threadand assert target/kwargs/start behavior instead.