I ran into this issue with daemons/scheduled jobs and "idle in transaction" in Django quite a while ago. I have a nice writeup of the problem and solution on this StackOverflow question if anybody's interested:
http://stackoverflow.com/questions/1303654/threaded-django-task-doesnt-automatically-handle-transactions-or-db-connections Ultimately it's a matter of being aware of what Django will, and will not, do for you. The lack of a request/response cycle from the daemon means that the usual connection-closing mechanism [signals.request_finished.connect(close_connection)] never gets triggered. Being a *web framework* it seems reasonable to me that it's built around requests/responses... - Gabriel On Sep 6, 10:09 am, Jordan <jordan.m.l...@gmail.com> wrote: > On Mon, 2010-09-06 at 16:47 +0200, Robert Gravsjö wrote: > > Can you please show me the code you're running to reproduce this? > > > Regards, > > roppert > > I've experienced what Patryk is describing here. It seems that the > Django ORM, when not explicitly in a transaction, doesn't commit or > rollback after each query. > > You can reproduce this simply in the dbshell. Go into your favorite > project and try this (replacing `myproject`, `myapp`, and `MyModel` > appropriately): > > from myproject.myapp import models > models.MyModel.objects.all()[:1] > > Now, in a superuser database connection, check the results of "select * > from pg_stat_activity." You should see the database connection from the > dbshell stuck in the "<IDLE> in transaction" state. > > Regards, > Jordan > > signature.asc > < 1KViewDownload -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.