Skip to content

mgedmin/dozer

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
October 27, 2022 12:01
October 27, 2022 11:57
December 2, 2015 10:05
October 27, 2022 11:57
June 14, 2008 16:40
April 23, 2019 12:31
November 13, 2020 09:38
August 1, 2022 12:51
October 27, 2022 11:57
February 8, 2019 16:02
April 22, 2021 22:51
December 8, 2020 09:26
October 27, 2022 11:57
October 27, 2022 11:57

Dozer

https://github.com/mgedmin/dozer/workflows/build/badge.svg?branch=master https://ci.appveyor.com/api/projects/status/github/mgedmin/dozer?branch=master&svg=true https://coveralls.io/repos/mgedmin/dozer/badge.svg?branch=master

Dozer was originally a WSGI middleware version of Robert Brewer's Dowser CherryPy tool that displays information as collected by the gc module to assist in tracking down memory leaks. It now also has middleware for profiling and for looking at logged messages.

Tracking down memory leaks

Usage:

from dozer import Dozer

# my_wsgi_app is a WSGI application
wsgi_app = Dozer(my_wsgi_app)

Assuming you're serving your application on the localhost at port 5000, you can then load up http://localhost:5000/_dozer/index to view the gc info.

Profiling requests

Usage:

from tempfile import mkdtemp
from dozer import Profiler

# my_wsgi_app is a WSGI application
wsgi_app = Profiler(my_wsgi_app, profile_path=mkdtemp(prefix='dozer-'))

Assuming you're serving your application on the localhost at port 5000, you can then load up http://localhost:5000/_profiler to view the list of recorded request profiles.

The profiles are stored in the directory specified via profile_path. If you want to keep seeing older profiles after restarting the web app, specify a fixed directory instead of generating a fresh empty new one with tempfile.mkdtemp. Make sure the directory is not world-writable, as the profiles are stored as insecure Python pickles, which allow arbitrary command execution during load.

Here's a blog post by Marius Gedminas that contains a longer description of Dozer's profiler.

Inspecting log messages

Usage:

from dozer import Logview

# my_wsgi_app is a WSGI application
wsgi_app = Logview(my_wsgi_app)

Every text/html page served by your application will get some HTML and Javascript injected into the response body listing all logging messages produced by the thread that generated this response.

Here's a blog post by Marius Gedminas that contains a longer description of Dozer's logview.