Threaded Django task doesn't automatically handle transactions or db connections?

Posted by Gabriel Hurley on Stack Overflow See other posts from Stack Overflow or by Gabriel Hurley
Published on 2009-08-20T02:26:48Z Indexed on 2010/05/15 9:14 UTC
Read the original article Hit count: 208

Filed under:
|
|
|
|

I've got Django set up to run some recurring tasks in their own threads, and I noticed that they were always leaving behind unfinished database connection processes (pgsql "Idle In Transaction").

I looked through the Postgres logs and found that the transactions weren't being completed (no ROLLBACK). I tried using the various transaction decorators on my functions, no luck.

I switched to manual transaction management and did the rollback manually, that worked, but still left the processes as "Idle".

So then I called connection.close(), and all is well.

But I'm left wondering, why doesn't Django's typical transaction and connection management work for these threaded tasks that are being spawned from the main Django thread?

© Stack Overflow or respective owner

Related posts about django

Related posts about python