Answers for "async stream python"

0

asyncio writer.write

import asyncio

async def tcp_echo_client(message):
    reader, writer = await asyncio.open_connection(
        '127.0.0.1', 8888)

    print(f'Send: {message!r}')
    writer.write(message.encode())
    await writer.drain()

    data = await reader.read(100)
    print(f'Received: {data.decode()!r}')

    print('Close the connection')
    writer.close()
    await writer.wait_closed()

asyncio.run(tcp_echo_client('Hello World!'))
Posted by: Guest on July-24-2020
0

async sleep python

import asyncio
await asyncio.sleep(1)
Posted by: Guest on December-08-2020

Python Answers by Framework

Browse Popular Code Answers by Language