I\'m trying to write simple web application using Tornado and JS Prototype library. So, the client can execute long running job on server. I wish, that this job runs Asynchronou
Tornado is single-threaded web server. Your while loop in wait_for_smith
method is blocking Tornado.
You can rewrite that method like this:
def wait_for_smth(self, callback, t=10):
if t:
print "Sleeping 2 second, t=%s" % t
tornado.ioloop.IOLoop.instance().add_timeout(time.time() + 2, lambda: self.wait_for_smth(callback, t-1))
else:
callback()
You need to add import time
at the top to make this work.