await function in Python

87 Views Asked by At

So this is some code i have in my python file, the details of the code aren't that important, I basically use this MainHandler to deal with some requests sent to it by a connection "client".

class MainHandler(tornado.web.RequestHandler):
   #some code
   async def connect(self):
      client = self.request.connection.stream
      #some code
      data = await client.read_bytes(10000, partial = True)

My doubt is if there's a way of waiting for the client.read_bytes() while a condition is still met. When that condition fails, I need to stop the "await".

0

There are 0 best solutions below