# accept_distributor

URL: /pounce/api/accept_distributor/
Section: api
Description: AcceptDistributor — single-thread accept feeding a shared worker queue.

Eliminates thundering herd on macOS/Windows where SO_REUSEPORT is
unavailable. One thread accepts connections and enqueues them into a
single shared queue from which all SyncWorkers pull.

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/accept_distributor/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Faccept_distributor%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Faccept_distributor%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Faccept_distributor%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2Faccept_distributor%2Findex.txt)

Module

#
`accept_distributor`

AcceptDistributor — single-thread accept feeding a shared worker queue.

Eliminates thundering herd on macOS/Windows where SO_REUSEPORT is
unavailable. One thread accepts connections and enqueues them into a
single shared queue from which all SyncWorkers pull.

1Class1Function

## Classes

`AcceptDistributor`

2

▼

Single thread that accepts connections and feeds a shared queue.

Used when SO_REUSEPORT is unavail…

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.

`def run(self) -> None`

Internal Methods
1

▼

`__init__`

6

▼

`def __init__(self, sock: socket.socket, conn_queue: queue.Queue[tuple[socket.socket, object]], *, config: ServerConfig | None = None, shutdown_event: threading.Event | None = None, drain_event: threading.Event | None = None, ssl_context: ssl.SSLContext | None = None) -> None`

##### Parameters

Name
Type
Description

`sock`
`—`

`conn_queue`
`—`

`config`
`—`

Default:`None`

`shutdown_event`
`—`

Default:`None`

`drain_event`
`—`

Default:`None`

`ssl_context`
`—`

Default:`None`

## Functions

`is_shared_socket`

1

`bool`

▼

True if all workers share the same socket (no SO_REUSEPORT).

`def is_shared_socket(sockets: list[socket.socket]) -> bool`

##### Parameters

Name
Type
Description

`sockets`
`list[socket.socket]`

##### Returns

`bool`
