File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed
Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ async def __aenter__(self) -> "AsyncClient":
159159 return self
160160
161161 async def __aexit__ (self , * args , ** kwargs ) -> None : # pyre-ignore
162+ """use async with to ensure close the client session after used"""
163+
164+ # we don't use `__del__` because close session requires `await`.
162165 await self .close ()
163166
164167 # high level functions
Original file line number Diff line number Diff line change @@ -138,6 +138,8 @@ async def worker() -> None:
138138 try :
139139 await asyncio .gather (* [t () for t in self .bg_tasks ])
140140 except asyncio .CancelledError :
141+ # when application is shutting down, tasks maybe cancelled.
142+ # ignore the error and shutdown the worker.
141143 return
142144 except Exception as e :
143145 self .logger .exception (e )
You can’t perform that action at this time.
0 commit comments