import time import sys from namedpipe import * if __name__ == '__main__': if len(sys.argv) < 2: print("need s or c as argument") elif sys.argv[1] == "s": with NamedPipeServer('testFoo') as server: count = 10 while count > 0: server.write(str(count)) time.sleep(1) count -= 1 elif sys.argv[1] == "c": with NamedPipeClient('testFoo') as client: while True: client.read() else: print(f"no can do: {sys.argv[1]}")