Fixes Python asyncio runtime error: event loop closed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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
Hey Man,
Where should i add this piece of code ?