Thursday, May 31, 2012

use of threading.Thread causes db connection leak

I discovered our webserver was leaking db connections because of the
use of threading.Thread in combination with the Django ORM. Looking
through the Django 1.4 release notes it seems that connection objects
are safe to share among threads. Is there something special that I
need to do to make sure the connections are closed? The background
threads are definitely terminating (they do a calculation and then put
the result in a Queue.Queue)

Some information about our setup:
Hosted on Heroku (Nginx)
Django 1.4
Postgres 9.1.3
psycopg 2.4.3

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment