I'm trying to implement long pulling client in Tornado, that interacts with an asynchronous Tornado server.
What happens is one of 2 things:
This is the client I use:
from tornado import ioloop
from tornado import httpclient
print "\nNon-Blocking AsyncHTTPClient"
import tornado.ioloop
def async_call(response):
if response.error:
response.rethrow()
print "AsyncHTTPClient Response"
ioloop.IOLoop.instance().stop()
http_client = httpclient.AsyncHTTPClient()
http_client.fetch("http://localhost:9999/text/", async_call)
ioloop.IOLoop.instance().start()
Is this the right way to write a long-polling/comet client?
I would also appreciate for those who will answer to provide a sample async-server in Tornado, because may be I'm writing the cometed Tornado server wrongly... I'm a bit new to the whole long-polling process in general.
Tornado itself has an excellent example of chat, built on top of long-polling mechanism
https://github.com/facebook/tornado/tree/master/demos/chat
It helped me a lot to understand everything, and it have both server and client.