On this page
asyncio.start_server
Prev: asyncio.sleep | Up: asyncio | Next: asyncio.start_unix_server
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.start_server
Tags: #public #python3 #stdlib #asyncio
Import
import asyncio
from asyncio import start_server
Signature & Overview
asyncio.start_server(client_connected_cb, host=None, port=None, *, limit=65536, **kwds)
Start a socket server, call back for each client connected.
Usage
import asyncio
# High-level TCP server:
# server = await asyncio.start_server(handle_client, "127.0.0.1", 0)
assert callable(asyncio.start_server)
Gotchas
- Use
async with server: await server.serve_forever(): Ensures clean socket shutdown and connection draining.
REPL Inspect
from asyncio import start_server
help(start_server)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/sleep Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/start_unix_server Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractEventLoop Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractServer Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/all_tasks Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/as_completed Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/Barrier shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseEventLoop shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseProtocol shared tags: #asyncio, #stdlib