Multiprocessing compatible memory leak debugger inspired by dozer/dowser
Project description
PyLoot
PyLoot is a memory leak detector based on Dozer and vprof with added support for process based server workloads.
This project is in active development and may contain bugs or otherwise work in ways not expected or intended.
Installation
$ pip install pyloot
Usage
from pyloot import PyLoot
loot = PyLoot()
"""
Collect objects still in `gc.get_objects` after a call to `gc.collect`.
"""
loot.collect_objects()
"""
Collecting data in a background thread every 30 seconds.
If gevent is detected, gevent.threadpool.spawn is used.
Otherwise, threading.Thread is used.
"""
loot.start()
"""
Stop running the collector background thread.
NOTE: This does not do a "final" collection.
To ensure objects were collected in a short lived execution, call collect_objects().
:param blocking: When true, wait until the thread has died
"""
loot.stop()
"""
Return a WSGI compatible application serving the PyLoot remote backend and
and the website.
:return: ::class::`PyLootServer`
"""
loot.get_wsgi()
Running embedded
Starlette/FastApi/ASGI
from pyloot import PyLoot
from fastapi import FastAPI
from starlette.applications import Starlette
from starlette.middleware.wsgi import WSGIMiddleware
app = FastAPI() # or Starlette()
pyloot = PyLoot()
app.on_event("startup")(pyloot.start)
app.mount("/_pyloot", WSGIMiddleware(pyloot.get_wsgi()))
Flask/WSGI
from pyloot import PyLoot
from flask import Flask
from werkzeug.middleware.dispatcher import DispatcherMiddleware
app = Flask(__name__)
pyloot = PyLoot()
app.on_before_first_request(pyloot.start)
app = DispatcherMiddleware(app, {
'/_pyloot': pyloot.get_wsgi()
})
Running in remote mode (multi-process servers)
# Embedded code
from pyloot import PyLoot
...
pyloot = PyLoot(host="127.0.0.1", port=8000)
...
# Start the remote server
$ pyloot --help
usage: pyloot [-h HOST] [-p PORT] [--help]
optional arguments:
-h HOST, --host HOST Host to listen on. (Default: 0.0.0.0)
-p PORT, --port PORT Port to listen on. (Default: 8000)
--help show this help message and exit
Bypass the multiprocessing check
If pyloot detects it is running in a multiprocessing environment with an inmemory backend it will refuse to serve the webpages/requests.
The WSGIMiddleware of starlette sets environ["wsgi.multiprocess"]=True regardless of the server.
This can by bypassed with a wrapper use with caution:
pyloot = PyLoot()
def pyloot_wrapper(wsgi_environ, start_response):
pyloot_environ = wsgi_environ.copy()
pyloot_environ["wsgi.multiprocess"] = False
wsgi = pyloot.get_wsgi()
return wsgi(pyloot_environ, start_response)
app.mount("/_pyloot", WSGIMiddleware(pyloot_wrapper))
Screenshots
View history of object counts by object group:
Modify history page size
Search history page
View objects by group
Modify objects fetch size
Modify objects page size
View an object, its attributes, repr, children, and parents
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyloot-0.0.5.tar.gz.
File metadata
- Download URL: pyloot-0.0.5.tar.gz
- Upload date:
- Size: 181.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bae50b8a7f0ad60bc0648d1e3660590b5a69b9e6908c3dad8183421e992310e3
|
|
| MD5 |
33d00fbbd153a9e70a33d860198ccdc0
|
|
| BLAKE2b-256 |
1c7ef66b7dd013d267c3fe1e199dc13443ba51de6bad14231f084f391d90a7e0
|
File details
Details for the file pyloot-0.0.5-py3-none-any.whl.
File metadata
- Download URL: pyloot-0.0.5-py3-none-any.whl
- Upload date:
- Size: 184.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2758625bfaf1248144189760b8b0856c6e1ef08934a09dda6dcc32b7305441c
|
|
| MD5 |
a76f5e8a29dd6906c1c5ac70309940b2
|
|
| BLAKE2b-256 |
5e3c29177a71b2e94a9849303992c6d9fd9f7a09fa1dff56dbc6ea3eb4f0c626
|