• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cjrh / deadpool / 46364666652
89%

Build:
DEFAULT BRANCH: main
Ran 30 Nov 2026 06:13AM UTC
Jobs 1
Files 13
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

30 Nov 2026 06:12AM UTC coverage: 88.129% (+0.03%) from 88.095%
46364666652

push

github

web-flow
Fix three races in how the pool counts and hands out workers (#452)

Four small races in how the pool counts and hands out workers. Each has
a deterministic test that forces the interleaving and fails on `main`.
No API change.

**1. A pool at its minimum can drop below it.** `done_with_process`
reads the busy count and then the idle count. A second worker that
finishes in between is in both, so the first one looks surplus and is
stopped. The default pool (no `min_workers`, so the minimum is
`max_workers`) is affected too: it loses a worker until the next
`get_process` finds none idle and starts one. Fixed by reading both
counts under `_workers_lock`.

**2. A task can wait although the pool has room.** `get_process` starts
a worker for a task and then takes one from the queue. Another task can
take that worker first, and the first then waits on the queue for a busy
worker to return. Fixed by starting and taking under a new lock,
`_checkout_lock`. When the pool really is full, the wait happens outside
it.

**3. `clear_workers` can block.** It checks `empty()` and then calls a
blocking `get()`; a task can take the last worker in between. Fixed with
`get_nowait`.

**4. `clear_workers` can strand a task.** A task counts one idle worker
and so does not start one; the clear takes that worker first; the task
then waits with nothing busy and nothing idle. Fixed by having the clear
take each worker under `_checkout_lock`. Workers are stopped outside it
and still one at a time, so a worker returned during the clear is
cleared too.

**Cost.** Worker starts are now one at a time per pool. Starting one
took 0.3 ms at the median and 6.5 ms at worst with forkserver here
(spawn 0.7 and 14.8, fork 0.5 and 1.4).

**Tests.** `tests/test_worker_accounting.py`. Reverting each fix on its
own fails its test.

The full suite passes on Python 3.10, 3.11, 3.12, 3.13, 3.14 and 3.14t
with the GIL off (203 passed on each, 3.14t four times). The new tests
ran 60 times, four at a ti... (continued)

771 of 961 branches covered (80.23%)

Branch coverage included in aggregate %.

22 of 22 new or added lines in 1 file covered. (100.0%)

2644 of 2914 relevant lines covered (90.73%)

5.43 hits per line

Jobs
ID Job ID Ran Files Coverage
1 46364666652.1 30 Nov 2026 06:14AM UTC 13
88.13
GitHub Action Run
Source Files on build 46364666652
  • Tree
  • List 13
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 8657bd96 on github
  • Prev Build on main (#46087112853)
  • Next Build on main (#46365171365)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc