0

I use aiohttp . at what places of app do I need to type await ? as I know there are cases:

  1. when code is about session

        async def get(self):
            session = await get_session(self.request)
    
    
  2. when code is about database

   def __init__(self, db, **kwargs):
           self.collection = db[MESSAGE_COLLECTION]

   async def save(self, user, msg, **kw):
           result = await self.collection.insert({'user': user, 'msg': msg, 'time': datetime.now()})
  1. when code is about sockets
   async def get(self):
           ws = web.WebSocketResponse()
           await ws.prepare(self.request)
user
  • 61
  • 7

0 Answers0