Skip to content

Instantly share code, notes, and snippets.

@DannyMor
Created April 15, 2020 18:43
Show Gist options
  • Save DannyMor/b7835dd2291f5ac1a5d49b3571c53276 to your computer and use it in GitHub Desktop.
Save DannyMor/b7835dd2291f5ac1a5d49b3571c53276 to your computer and use it in GitHub Desktop.
async def close(self) -> None:
if self.quota_consumer_task and not self.quota_consumer_task.cancelled():
try:
self.quota_consumer_task.cancel()
await self.quota_consumer_task
except asyncio.CancelledError:
# ignore the error here but log to inform the task was cancelled
pass
except Exception as e:
# log and deal with the error here
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment