On Wed, Nov 05, 2008 at 11:21:14AM -0800, russellneufeld wrote:
> The one thing left that I'd like to do is set up Django to run
> continuously, even when there are no http requests. My application
> runs a bunch of periodic background tasks in addition to serving up
> web content, and it seems that after a few minutes with no web
> activity, the app is terminated. I'm coming from the java world where
> you typically have one long-running jvm which handles all requests and
> does not start and stop with new Apache instances. I'd like to set up
> something similar with Django.
With Django all state is in the database(unless you've setup cookies).
There's no guaranteed persistent process. You'll need to use whatever
periodic scheduler Dreamhost gives you (cron, other?) to run your
background tasks as separate python scripts. Here's an example:
#!/usr/bin/python
import sys
# This is my django model that I want to do something with
from mfg.bundle.models import Bundle
try:
bundles = Bundle.objects.all()
for bundle in bundles:
bundle.do_something()
except:
print "Something went crazy wrong!"
sys.exit(1)
sys.exit(0)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---