Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixes Python asyncio runtime error: event loop closed
"""fix yelling at me error"""
from functools import wraps
from asyncio.proactor_events import _ProactorBasePipeTransport
def silence_event_loop_closed(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except RuntimeError as e:
if str(e) != 'Event loop is closed':
raise
return wrapper
_ProactorBasePipeTransport.__del__ = silence_event_loop_closed(_ProactorBasePipeTransport.__del__)
"""fix yelling at me error end"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment