pipe-io-server/echo_server.py
2019-05-09 13:46:31 +02:00

21 lines
593 B
Python

from signal import signal, SIGTERM, SIGINT
from pipe_io_server import PipeIOServer
class EchoPipeIOServer(PipeIOServer):
def handle_message(self, message):
self.send_message(message)
if __name__ == "__main__":
pipe_io = EchoPipeIOServer('in', 'out')
signal(SIGTERM, lambda a, b: pipe_io.stop())
signal(SIGINT, lambda a, b: pipe_io.stop())
pipe_io.on_stop = lambda: print('Stopping...')
pipe_io.start()
print('Running pipe IO server with named pipes:')
print(f'Input: {pipe_io.in_pipe}')
print(f'Output: {pipe_io.out_pipe}')
pipe_io.wait()