On 12/12/10 12:10, Craig Trader wrote: > What I would like to be able to do is to have my background process > close and/or reset its database connection, as often as necessary. > > Thank you in advance for any assistance you can render.
Yeah, note that django normally actually closes the connection after processing of each http request [1] We use django-celery, and so we install a signal handler for the "task_postrun" signal celery fires upon task completion to try to do similar upon completion of that each celery task. [2] (I never proved the super-long-running connections were really an issue for us, it was a pre-emptive thing based on other people's problem reports, but we haven't had any problems in the area since...) Basically, you probably just need to pick an opportune moment to do similar in your vaguely-celery-like-thingy - each time a processor has completed a job from your queue, say, have it close the connection. You could involve signal handling if you wanted to structure things that way, or not. [1] http://code.djangoproject.com/browser/django/trunk/django/db/__init__.py#L85 [2] from django.db import reset_queries, close_connection from celery.signals import task_prerun, task_postrun task_prerun.connect(reset_queries, dispatch_uid=__name__) task_postrun.connect(close_connection, dispatch_uid=__name__) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.