What you see is actually a browser limitation, not a problem with your code. I have added some additional protocols to your TestHandler so that this becomes clear:
class TestHandler(tornado.web.RequestHandler): # localhost:8888/test @tornado.web.asynchronous def get(self): print "Thread starting %s" % time.time() t = threading.Thread(target = self.newThread) t.start() def newThread(self): print "new thread called, sleeping %s" % time.time() time.sleep(10) self.write("Awake after 10 seconds!" % time.time()) self.finish()
If I simultaneously open two curl sessions for localhost / test, I get this on the server side:
Thread starting 1402236952.17 new thread called, sleeping 1402236952.17 Thread starting 1402236953.21 new thread called, sleeping 1402236953.21
And this is on the client side:
Awake after 10 seconds! 1402236962.18 Awake after 10 seconds! 1402236963.22
This is exactly what you expect. However, in Chromium, I get the same behavior as you. I think that Chromium (possibly all browsers) will only allow one connection to open one URL at a time. I confirmed this by doing IndexHandler running the same code as TestHandler , with the exception of a few different log messages. Here's the output when opening two browser windows, one on /test and one on /index :
index Thread starting 1402237590.03 index new thread called, sleeping 1402237590.03 Thread starting 1402237592.19 new thread called, sleeping 1402237592.19
As you can see, both started simultaneously without any problems.
source share