when trying to fetch data from a tornado GET method, if we need a result to be returned, the call has to be a blocking call which returns a value to the client (if we’re fetching data from some third party, the result gets all the more delayed and the call is blocked till then).
Is there a way I could return processed values to the client and still have non-blocking calls in Tornado?
As suggested by Sushant Khurana, you could “monkey patch” urllib2. Fortunately, you don’t have to do it yourself: someone else has done it for you!
Check out eventlet: http://eventlet.net/doc/index.html
It basically implements its own asynchronous versions of
socket,urllib2,asyncore, etc.Check out its documentation and this blog post.
I’ve never used it myself, but it look promising!