Snippet List
FastCGI handler in prefork mode first imports every application, then forks. If any application during import opens connection to database, open connection is inherited by all of child processes; open db connection cannot be shared between processes, and if one process sends a request, another can receive a reply; also, if one process closes it, others have a desynchronized database handle.
See:
* http://stackoverflow.com/questions/1573579/psycopg2-disconnects-from-server
* http://stackoverflow.com/questions/393637/django-fastcgi-randomly-raising-operationalerror
* http://code.djangoproject.com/ticket/13215
* http://groups.google.com/group/django-users/browse_thread/thread/2c7421cdb9b99e48
If you put this snippet in your project-level __init__.py, then running manage.py runfcgi will fail loudly if the database connection is open in the parent process. This will happen only when you provide debug=true option to runfcgi to avoid monkey-patching code that runs in production mode.
Middleware class logging request time to stderr.
This class can be used to measure time of request processing within Django. It can be also used to log time spent in middleware and in view itself, by putting middleware multiple times in INSTALLED_MIDDLEWARE.
Static method `log_message' may be used independently of the middleware itself, outside of it, and even when middleware is not listed in INSTALLED_MIDDLEWARE.
Invokes [pyflakes](http://divmod.org/trac/wiki/DivmodPyflakes) diagnostic tool as a `manage.py` command. Save as `flakes.py`, since `pyflakes.py` will collide with `pyflakes` module.
I needed to invoke pyflakes as management command, because I alter `sys.path` in my `manage.py`, so system-wide pyflakes would not see project-local modules.
Provides possibility of ignoring warnings by adding text `pyflakes:ignore` in a comment at end of offending line. Returns non-zero status to system when non-ignored warnings are found.
Accepts list of directories or files as arguments. When no arguments are given, `PYFLAKES_DEFAULT_ARGS` setting is used (list of strings, by default `['.']`).
- management
- pyflakes
- flakes
mpasternacki has posted 5 snippets.