Weird "bugs" in EPollReactor? You may be using the reactor from a thread by mistake
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#...
participants (1)
-
Chris Withers