Hi All,
So, this was "fun"... Eventually tracked down a bug in Twisted based
application that uses Autobahn for websockets, some AMP stuff and a good
amount of other Twisted stuff, but that has to call a bunch of blocking
code, some of it written by users of the app, so we want to insulate
them from thinking about Deferreds or anything async.
We saw weird KeyErrors, ENOENT, "Reactor was unclean" during shutdown in
trial-based test suites and generally head-in-sanded it or grumbled
about CI instability due to the environment in which the tests were
running. This went on for a couple of years... no kidding...
Just recently, finally spotted the problem... a bunch of handler code
was being deferToThread'ed so that it didn't accidentally block the
reactor, BUT it was also calling sendMessage [1]...
Big "d'oh" when that penny finally dropped...
Moving that code to using blockingCallFromThread magically fixed all the
"reactor bugs" and "CI environment instability", so wanted to write
something up here for future self or google hunters...
More over on Stack Overflow:
https://stackoverflow.com/a/75674510/216229
cheers,
Chris
[1]
https://autobahn.readthedocs.io/en/latest/reference/autobahn.websocket.html#autobahn.websocket.interfaces.IWebSocketChannel.sendMessage
_______________________________________________
Twisted mailing list -- twisted@python.org
To unsubscribe send an email to twisted-le...@python.org
https://mail.python.org/mailman3/lists/twisted.python.org/
Message archived at
https://mail.python.org/archives/list/twisted@python.org/message/LSDB2H2JJYMISVHYV2UTYX5HHXWGIF2Q/
Code of Conduct: https://twisted.org/conduct