Skip to content

Instantly share code, notes, and snippets.

@dimaqq
Created March 5, 2020 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaqq/d2f55581f94c6a8e4aa3fc90aa54924f to your computer and use it in GitHub Desktop.
Save dimaqq/d2f55581f94c6a8e4aa3fc90aa54924f to your computer and use it in GitHub Desktop.
fut = None
async def antidogpile(coro, *args, **kwargs):
nonolocal fut
async def helper():
nonlocal fut
try:
return await coro(*args, **kwargs)
finally:
fut = None
if fut is None:
fut = asyncio.shield(helper())
return await fut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment