pytest-dev / pytest-dev/pytest

Limit memory usage for captured logs or stdout

Open
#9,215 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: capture type: performance
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

I've recently spent some time debugging a test suite that started OOM'ing. The culprit was a runaway greenlet which logged as fast as it could, but due to caplog's disposition to store logs until test's end, the memory leak was well obscured from me. It was even stranger since due to its nature (a runaway greenlet), I couldn't attribute it to any particular greenlet, yet the longer the test suite ran, the more memory it leaked.

Maybe we could implement practical per-test and per-suite log capturing limits, which could be bumped through configuration, but otherwise would be helpful for cases such as these?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing pytest's caplog and stdout capture entry points to understand where output is retained for a test and for the suite. Define practical configurable limits and determine what behavior should occur when they are reached; done means runaway captured output cannot cause unbounded memory growth while normal test capture remains useful.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.