Initial commit
This commit is contained in:
24
playground/asyncio_test.py
Normal file
24
playground/asyncio_test.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import asyncio
|
||||
|
||||
|
||||
async def tcp_echo_client(message):
|
||||
reader, writer = await asyncio.open_connection('server', 7072)
|
||||
print("Connected")
|
||||
|
||||
lines = [
|
||||
"displayattr .*\n".encode(),
|
||||
"inform on\n".encode(),
|
||||
]
|
||||
writer.writelines(lines)
|
||||
|
||||
while True:
|
||||
data = await reader.readline()
|
||||
data = data.decode()
|
||||
print("Received line", data)
|
||||
|
||||
|
||||
#asyncio.run(tcp_echo_client('Hello World!'))
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(tcp_echo_client("bla"))
|
||||
loop.close()
|
||||
Reference in New Issue
Block a user