-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make HTTP requests sent by games to the lamp server asynchronous #73
Comments
Not that high priority |
I recommend using CurlAsyncHTTPClient which is much, much faster than the default async HTTP client in Tornado. In the light server we do the following: try:
import tornado.curl_httpclient
tornado.httpclient.AsyncHTTPClient.configure(tornado.curl_httpclient.CurlAsyncHTTPClient)
except ImportError:
logging.warning("Couldn't import CurlAsyncHTTPClient, reverting to slow default implementation") Afterwards the HTTP client can be instantiated by running AsyncHTTPClient.fetch returns a Future. If you want to wait for the Future to return in a pseudo-synchronous manner, you can use coroutines: @tornado.gen.coroutine
def func():
future = asyncclient.fetch(URL)
response = yield future Upon yielding the function will suspend execution, and tornado.gen.coroutine will intercept the yielded Future. When the Future completes tornado.gen.coroutine will return control to the suspended function, and will send the Future's result as the result of the yield expression. Any function decorated by tornado.gen.coroutine will in turn return a Future that completes when the function completes, with the result of the Future being the value returned by the function using the Alternatively, the IOLoop object provides an add_future method that takes a Future and a callback that will be called with the Future as an argument when the Future completes. In addition, AsyncHTTPClient.fetch has a callback argument. |
I don't have time to work on this anymore today (I'm travelling south over the extended weekend tomorrow), but I'll summarize what I've figured about "async-ing" the lamp-server connection.
Anyway, anyone is free to pick this up if they want to. The above links should make it clear what needs to be changed, I just don't have time to implement and test it today. |
No description provided.
The text was updated successfully, but these errors were encountered: