diff --git a/solvable/src/event_handler_main.py b/solvable/src/event_handler_main.py index 64fc82a..2b5ae62 100644 --- a/solvable/src/event_handler_main.py +++ b/solvable/src/event_handler_main.py @@ -165,10 +165,8 @@ def main(): key='test' ) - event_handlers = EventHandler.get_local_instances() - def stop(sig, frame): # pylint: disable=unused-argument - for eh in event_handlers: - eh.stop() + def stop(*_): + EventHandler.stop_all_instances() exit(0) signal(SIGTERM, stop) signal(SIGINT, stop) diff --git a/solvable/src/pipe_io_main.py b/solvable/src/pipe_io_main.py index fabd772..1e9e26b 100644 --- a/solvable/src/pipe_io_main.py +++ b/solvable/src/pipe_io_main.py @@ -4,7 +4,7 @@ from signal import signal, SIGTERM, SIGINT from tornado.ioloop import IOLoop -from tfw.event_handlers import EventHandlerBase +from tfw.builtins import EventHandler from tfw.builtins import PipeIOEventHandler from tfw.config import TFWENV from tfw.logging import Log, Logger, LogFormatter, VerboseLogFormatter @@ -19,23 +19,13 @@ from pipe_io_auxlib import ( LOG = logging.getLogger(__name__) -if __name__ == '__main__': +def main(): + # pylint: disable=unused-variable Logger([ Log(stderr, LogFormatter(20)), Log(TFWENV.LOGFILE, VerboseLogFormatter()) ]).start() - """ - Creates general purpose pipes. - The first parameter associates the receiving pipe with a key, which is - an empty string in this case. It has a special meaning, you can - subscribe to every kind of message with this key. - If you wish to filter incoming data, specify a single or more keys in - a list, eg.: processmanager, ide, key... - You can send/receive JSON messages to/from the TFW server as any user, - because we gave read+write permissions, without that parameter, only - the owner has access to the pipes. - """ json_pipe = PipeIOEventHandler( '', '/tmp/tfw_json_send', @@ -77,12 +67,14 @@ if __name__ == '__main__': '/tmp/tfw_fsm_recv' ) - event_handlers = EventHandlerBase.get_local_instances() - def stop(sig, frame): # pylint: disable=unused-argument - for eh in event_handlers: - eh.stop() + def stop(*_): + EventHandler.stop_all_instances() exit(0) signal(SIGTERM, stop) signal(SIGINT, stop) IOLoop.instance().start() + + +if __name__ == '__main__': + main()