a blog by Marius Gedminas

Posts tagged Python

logging.config.fileConfig gotcha

If you use logging.config.fileConfig (e.g. because you use paster serve something.ini to deploy your WSGI apps) you should know about this. By default fileConfig disables all pre-existing loggers if they (or their parent loggers) are not explicitly mentioned in your .ini file. This can result in unintuitive behaviour: (if you don't see the embedded example, you can find it at https://gist.github.com/1642893). If you have Python 2.6 or later (and you should), you can turn this off by passing disable_existing_loggers=False to fileConfig().

Stuff I've been doing recently

objgraph got shiny documentation built with Sphinx. Python 3.x support, thanks to Stefano Rivera. Python 2.4 and 2.5 support, thanks to Daniel Blackburn. assorted smaller improvements. zodbbrowser got support for all ZODB databases, not just those with a Zope 3/Bluebream-style root folder/local site. the ability to cope better with broken objects (due to the way ZODB works, not having some of your modules on the Python pack can break unpickling; zodbbrowser now handles this kind of situation better).

Profiling with Dozer

Dozer is mostly known for its memory profiling capabilities, but the as-yet unreleased version has more. I've talked about log capturing, now it's time for Profiling This WSGI middleware profiles every request with the cProfile module. To see the profiles, visit a hidden URL /_profiler/showall: What you see here is heavily tweaked in my fork branch of Dozer; upstream version had no Cost column and didn't vary the background of Time by age (that last bit helps me see clumps of requests).