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

aio-libs / multidict / 36039339303
86%

Build:
DEFAULT BRANCH: master
Ran 24 Sep 2026 06:10PM UTC
Jobs 1
Files 43
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

24 Sep 2026 06:09PM UTC coverage: 87.146% (-0.5%) from 87.672%
36039339303

push

github

web-flow
Add a watchers C API (#1551)

<!-- Thank you for your contribution! -->

## What do these changes do?

Add a watchers C API, so another C extension can be notified when a
`MultiDict` or `CIMultiDict` changes. It follows CPython's
`PyDict_AddWatcher` family, with two deliberate differences.

The callback gets **two context pointers**: `watcher_data`, fixed when
the
callback is registered, and `user_data`, belonging to one watched
multidict. That is the point of the API: one registered callback can
serve
any number of multidicts and still know, on every event, what owns the
one
that changed. CPython does not need this because its dict watchers are
static functions inside the interpreter.

Events are **delivered after the operation finishes**, not mid-mutation.
Several of the update paths run with the table deliberately inconsistent
(`_md_del_at_for_upd_deferred` leaves an entry half-deleted but still
reachable until `md_post_update` sweeps it, and
`_md_replace`/`_md_update`
carry a `reflist_t` of not-yet-decref'd objects), so calling out to a
client there is the shape behind #1469 and #1489. Events are recorded
into
a per-multidict log instead, which only allocates, and delivered once
the
critical section is released.

The events are multi-value aware, since `add()` on a key that is already
present is an append rather than a modification, and one `__setitem__`
can
both replace a pair and delete several. Each event that concerns a key
carries the identity alongside it, already lowercased for a
`CIMultiDict`,
so a watcher matching `"content-length"` needs no `lower()` of its own,
and
the identity's hash with it, so a watcher keeping its own table does not
have to hash the key again.

C-extension only, like the rest of the capsule API: `_multidict_py.py`
and
`_abc.py` are untouched, and `tests/test_capi.py` skips on the
pure-Python
leg as it already does.

`MultiDict_CAPI_VERSION` stays at 1: version 1 has not shipped, since
7.0
is unreleased, so no client... (continued)

778 of 1556 branches covered (50.0%)

Branch coverage included in aggregate %.

282 of 381 new or added lines in 1 file covered. (74.02%)

7968 of 8480 relevant lines covered (93.96%)

1.88 hits per line

Uncovered Changes

Lines Coverage ∆ File
99
75.22
-1.45% tests/test_capi.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 36039339303.1 24 Sep 2026 06:10PM UTC 86
87.14
GitHub Action Run
Source Files on build 36039339303
  • Tree
  • List 43
  • Changed 3
  • Source Changed 1
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #36039339303
  • e09ae77a on github
  • Prev Build on master (#36020212647)
  • Next Build on master (#36043151885)
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