Classes
AcceptDistributor
2
▼
Single thread that accepts connections and feeds a shared queue.
Used when SO_REUSEPORT is unavail…
AcceptDistributor
2
▼
Single thread that accepts connections and feeds a shared queue.
Used when SO_REUSEPORT is unavailable (macOS, Windows). Avoids thundering herd where all workers block on accept() on the same fd.
All SyncWorkers pull from the same shared queue so the first idle worker handles the next connection — no head-of-line blocking.
Methods
run
0
▼
Accept connections and enqueue for workers until shutdown.
run
0
▼
def run(self) -> None
Internal Methods 1 ▼
__init__
4
▼
__init__
4
▼
def __init__(self, sock: socket.socket, conn_queue: queue.Queue[tuple[socket.socket, object]], *, shutdown_event: threading.Event | None = None, ssl_context: ssl.SSLContext | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
sock |
— |
|
conn_queue |
— |
|
shutdown_event |
— |
Default:None
|
ssl_context |
— |
Default:None
|
Functions
is_shared_socket
1
bool
▼
True if all workers share the same socket (no SO_REUSEPORT).
is_shared_socket
1
bool
▼
def is_shared_socket(sockets: list[socket.socket]) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
sockets |
list[socket.socket] |
Returns
bool