pipe-io-server/echo_server.py

20 lines
542 B
Python
Raw Normal View History

from signal import signal, SIGTERM, SIGINT
from pipe_io_server import PipeIOServer
class EchoPipeIOServer(PipeIOServer):
2018-12-16 18:16:01 +00:00
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())
2019-04-10 10:40:51 +00:00
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()