Opened 6 years ago
#5153 enhancement new
Add an equivalent to `isInIOThread` as a reactor method
|Reported by:||Jean-Paul Calderone||Owned by:|
twisted.python.threadable.isInIOThread is usable to determine if the code calling it is executing in the same thread as the reactor. This may be useful for making certain decisions (though Twisted doesn't currently use it anywhere outside of the test suite).
Notice the problem with that, however: the reactor. This API gets in the way of supporting multiple reactors, since its behavior no longer makes any sense once you have reactors running in more than one thread.
It could be replaced by a new reactor method which determines if the calling code is running in the same thread as the reactor the method is called on is running. This probably makes sense as a method on
IReactorThreads, if we're allowed to add new methods to reactor interfaces (I forget if we are or not).
Once this is in place, we can deprecate
twisted.python.threadable.isInIOThread and point at the reactor method to replace it.