Commit 33f28665 by Oleksandr Barabash

_ProactorBasePipeTransport updated

parent e664f34a
...@@ -6,6 +6,7 @@ import os ...@@ -6,6 +6,7 @@ import os
import signal import signal
import sys import sys
from asyncio import AbstractEventLoop from asyncio import AbstractEventLoop
from functools import wraps
from threading import Thread from threading import Thread
from typing import Any, Optional from typing import Any, Optional
...@@ -25,6 +26,26 @@ flags.DEFINE_list('station_ids', [], 'Station IDs') ...@@ -25,6 +26,26 @@ flags.DEFINE_list('station_ids', [], 'Station IDs')
flags.DEFINE_string('file', None, "File where to save the history") flags.DEFINE_string('file', None, "File where to save the history")
def silence_event_loop_closed(func):
""" prevent error when closing on windows """
@wraps(func)
def wrapper(self, *args, **kwargs):
""" wrapper """
try:
return func(self, *args, **kwargs)
except RuntimeError as e:
if str(e) != 'Event loop is closed':
raise
return wrapper
if sys.platform == "win32":
from asyncio.proactor_events import _ProactorBasePipeTransport
_ProactorBasePipeTransport.__del__ = silence_event_loop_closed(
_ProactorBasePipeTransport.__del__
)
class PacketLogger(abc.ABC): class PacketLogger(abc.ABC):
""" Abstract Logger """ """ Abstract Logger """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment