pipe-io-server/echo_server.py

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