pipe-io-server/echo_server.py
2019-04-10 12:40:51 +02:00

19 lines
515 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)
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.start()
print('Running pipe IO server with named pipes:')
print(f'Input: {pipe_io.in_pipe}')
print(f'Output: {pipe_io.out_pipe}')