I am just trying to understand that if when I call time.sleep(x), the current thread that is running the code gets delayed by x seconds. But does that free up the processor for those x seconds or does the thread keep the resources to itself and after x seconds it just starts executing the next lines of code.
Editing with the exact scenario I am facing:
Here's the case with me:
class SomeHandler(tornado.websocket.WebSocketHandler)
@tornado.gen.coroutine
def something_async():
time.sleep(5)
return result
def on_message(message):
future = yield something_async(message)
if __name__ == '__main__':
application = tornado.web.Application([
(r'/', SomeHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Now since this Tornado will be a single threaded server, What exactly does time.sleep(5) do in this case (will it just block the thread for 5 seconds making the whole process synchronous) or the coroutine spawns a new thread?