I am using the Django ORM to build and manipulate models from outside of a web context and within a long running daemonized application. I'm using the django ORM talking to a postgresql db for this processing since the results of this external processing are then used by a Django based web reporting application and it was exceptionally convenient to have a library that acted on these objects in a consistent way regardless of whether it was called from the daemon vs from a web request.
I've been seeing more and more database errors occurring within the external processor. For example, I get a lot of these: InternalError: current transaction is aborted, commands ignored until end of transaction block I get a few of these: InternalError: SET TRANSACTION ISOLATION LEVEL must be called before any query The postgresql logs are not very descriptive as to what the root problem is: 2009-08-04 14:04:08 EDT STATEMENT: BEGIN; SET TRANSACTION ISOLATION LEVEL READ COMMITTED 2009-08-04 14:04:14 EDT ERROR: current transaction is aborted, commands ignored until end of transaction block The research I've seen so far leads me to think the problem is that the ORM is building transactions that ordinarily would be closed at the end of a view, but are being kept open in my case since I really don't have a 'view' life-cycle. I've tried decorating my db-hitting routines in the daemon code with django.db.transaction.commit_manually along with appropriate calls to commit() and rollback() in case of error, yet the problem persists. I've read the docs (and some of the code) associated with transactions, yet the focus (naturally) is on views and functions that have a typical request/response lifecycle. I'm wondering what suggestions people would have for using the ORM in a long running daemon (e.g. should I be closing the db connection periodically? how would you suggest managing the transactions?). The basic flow of my code is: daemonize my process while True: listen for an external event (e.g. from the net) process that event into model based objects save the objects Any help would be appreciated. -- William --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---