Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, I'm not async expert at all, I just investigated the topic once. IMHO if you're using XAMPP then you're loosing the posibility of doing long polling because Apache uses thread/processes (depending on configuration) for each request.</p> <p>What you need, is non-blocking web server, like <a href="http://www.tornadoweb.org/" rel="noreferrer">Tornado</a>, that allows splitting requests into two parts, of which the second one is fired on some event, but meanwhile server can accept subsequent inbound requests.</p> <p>Example from <a href="http://www.tornadoweb.org/documentation" rel="noreferrer">Tornado documentation</a> /<a href="http://creativecommons.org/licenses/by/3.0/" rel="noreferrer">license</a>/:</p> <pre><code>class MainHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self): http = tornado.httpclient.AsyncHTTPClient() http.fetch("http://friendfeed-api.com/v2/feed/bret", callback=self.async_callback(self.on_response)) def on_response(self, response): if response.error: raise tornado.web.HTTPError(500) json = tornado.escape.json_decode(response.body) self.write("Fetched " + str(len(json["entries"])) + " entries " "from the FriendFeed API") self.finish() </code></pre> <p>-- as far as I know this is not possible under Apache - in which fetch is regular part of request handler, which of course block until it's complete - so what you end with is frozen thread or process.</p> <p>Another famous library for doing non-blocking services in Python is <a href="http://twistedmatrix.com/trac/" rel="noreferrer">Twisted</a>, but I don't know much about it, only that it also is able to help you in handling a lot of connections with only one thread/process.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload