Skip to main content

Detects thread leaks

Project description

See Build Status on Travis CI See Build Status on AppVeyor

Detects tests leaking threads


You can install “pytest-threadleak” via pip from PyPI:

$ pip install pytest-threadleak


The threadleak pytest plugin will fail leaking threads. This can be an issue in the test, or in the tested code.

Here is an example leaking test:

$ cat
import threading
import time

def test_leak():
    threading.Thread(target=time.sleep, args=(1,)).start()

Here is an example run with thread leak plugin enabled:

$ pytest --threadleak
>   ???
E   Failed: Test leaked [<Thread(Thread-1, started 139762716391168)>]

If you want to enable thread leak by default, you can enable it in your pytest.ini or tox.ini:

threadleak = True


Running the tests:

$ tox


Distributed under the terms of the MIT license, “pytest-threadleak” is free and open source software


This Pytest plugin was generated with Cookiecutter along with @hackebrot’s Cookiecutter-pytest-plugin template.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-threadleak, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest-threadleak-0.2.0.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page