Twisted FAQs clearly state that "deferreds do not magically convert blocking code into non-blocking code". So, how do you magically convert blocking code into non-blocking code?
This recipe is the solution!
Python, 47 lines
How to make blocking code non-blocking is the obvious question for everybody using Twisted, but the Twisted documentation does not make easy to find the solution :-(
The trick is to run the blocking function in a separate thread. Here
all the magic is performed by the decorator,
In short: every time you have a blocking function in your code, wrap
it with the