Tornado: Blocked on asyncio.sleep

Created on 13 Aug 2018  路  1Comment  路  Source: tornadoweb/tornado

When running this code, it seems that I'm unable to open multiple simultaneous connections to the server. Maybe tornado is blocked on the asyncio.sleep()? Is this behaviour expected?

I've tested this on 5.0.1, 5.1 and master.

class MainHandler(tornado.web.RequestHandler):

    async def get(self):
        sleep = random.randrange(10)
        logger.info('REQUEST will sleep for {}'.format(sleep))
        await asyncio.sleep(sleep)
        logger.info('woke up')
        self.write('Ok')

def main():
    logging_setup()
    tornado.platform.asyncio.AsyncIOMainLoop().install()
    application = tornado.web.Application([
        (r"/", MainHandler),
    ])
    application.listen(8000)
    tornado.ioloop.IOLoop.current().start()

Most helpful comment

Are you using a browser? Take a look at the bottom of the FAQ page: http://www.tornadoweb.org/en/stable/faq.html

>All comments

Are you using a browser? Take a look at the bottom of the FAQ page: http://www.tornadoweb.org/en/stable/faq.html

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Carl7189 picture Carl7189  路  4Comments

AbsoluteVirtue picture AbsoluteVirtue  路  5Comments

zooba picture zooba  路  5Comments

kmike picture kmike  路  6Comments

christippett picture christippett  路  5Comments