-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (28 loc) · 898 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import asyncio
import datetime
import pipe_py
async def main():
pc = pipe_py.PipeClient(
"pipe.pico.sh", 22, "keyfile"
)
async def pipe():
a = await pc.pipe("foobar3")
while True:
data = await a.read()
await a.write(f"PIPE: {data}")
print(f"Echoing data: {data}")
async def sub():
a = await pc.sub("foobar2")
while not a.read_done():
data = await a.read()
print(f"Read data: {data}")
async def pub():
a = await pc.pub("foobar")
while True:
current_time = datetime.datetime.now()
await a.write(f"PUB: {current_time}\n")
print(f"Write data: {current_time}")
await asyncio.sleep(1)
await asyncio.gather(pipe(), sub(), pub(), return_exceptions=True)
if __name__ == "__main__":
asyncio.run(main())