Skip to content
Discussion options

You must be logged in to vote

asyncio.start_server() returns a Server instance. It runs a background task which accepts connections as they occur, calling the callback each time this occurs. So the correct call pattern is:

my_server = await asyncio.start_server(cb, host, port)

The my_server instance should be retained in case you need to issue my_server.close() but, aside from that, all connections are handled by the callback which gets reader and writer streams for that particular connections.

Note that the event loop code is obsolescent. See the tutorial.

Host addresses should be from socket.getaddrinfo().

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DavesCodeMusings
Comment options

Answer selected by DavesCodeMusings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants