Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def direct_cancel():
"""Reach inside, find the one task that is marked "do not cancel"
for shutdown, and then cancel it directly. This should raise
CancelledError at the location of the caller for
`shutdown_waits_for()`."""
tasks = all_tasks()
for t in tasks: # pragma: no cover
if t._coro in _DO_NOT_CANCEL_COROS:
t.cancel()
return