twisted / twisted

Event-driven networking engine written in Python.
https://www.twisted.org
Other
5.44k stars 1.14k forks source link

#11771 make cfreactor less flaky #12160

Closed glyph closed 2 weeks ago

glyph commented 2 weeks ago

Scope and purpose

Fixes #11771

This is the change that appeared to have made a difference isolated and extracted from #12150 .

glyph commented 2 weeks ago

Both of the failures are in twisted.internet.test.test_tcp.AbortConnectionTests_CFReactorTests.test_fullWriteBuffer, which also fails sometimes in the asyncioreactor too: https://github.com/twisted/twisted/issues/12151

so I think this fix actually resolves the issue

glyph commented 2 weeks ago

please review

glyph commented 2 weeks ago

Were you able to reproduce the errors on your local system?

I was not. But in every other case I managed to reproduce the error in CI after a minimum of 5 tries.

The race condition here is extremely subtle, and I couldn't even think of a white-box test to reproduce it, but basically if something were to call _scheduleSimulate without force after calling it with force, so logically I think I see how this hang could happen.