| import asyncio
|
| from argparse import ArgumentParser
|
| from pathlib import Path
|
|
|
|
|
| async def handle(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
|
| while buf := await reader.read(4096):
|
| print(buf)
|
|
|
|
|
| async def main() -> None:
|
| parser = ArgumentParser()
|
| parser.add_argument("path", type=Path)
|
|
|
| args = parser.parse_args()
|
|
|
| server = await asyncio.start_unix_server(handle, path=args.path)
|
|
|
| async with server:
|
| await server.serve_forever()
|
|
|
|
|
| if __name__ == "__main__":
|
| asyncio.run(main())
|