File: multidict_extend_multidict.py

package info (click to toggle)
python-multidict 6.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 896 kB
  • sloc: ansic: 6,634; python: 4,399; makefile: 227
file content (21 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gc
import sys

import objgraph  # type: ignore[import-untyped]

from multidict import MultiDict


def _run_isolated_case() -> None:
    md: MultiDict[str] = MultiDict()
    for _ in range(100):
        md.extend(MultiDict())
    del md
    gc.collect()
    leaked = len(objgraph.by_type("MultiDict"))
    print(f"{leaked} instances of MultiDict not collected by GC")
    sys.exit(1 if leaked else 0)


if __name__ == "__main__":
    _run_isolated_case()