Functions
maybe_pin_worker
2
None
▼
Pin the current thread/process to a CPU core when enabled on Linux.
Called at …
maybe_pin_worker
2
None
▼
def maybe_pin_worker(worker_id: int, config: ServerConfig) -> None
Pin the current thread/process to a CPU core when enabled on Linux.
Called at worker startup. No-op when:
- cpu_affinity is False
- Not running on Linux (os.sched_setaffinity is Linux-only)
- sched_setaffinity raises (e.g. restricted cpuset in containers)
Parameters
| Name | Type | Description |
|---|---|---|
worker_id |
int |
Worker index (0, 1, ...). |
config |
ServerConfig |
Server configuration (reads cpu_affinity). |