On Nov 6, 4:00 pm, "DULMANDAKH Sukhbaatar" <[EMAIL PROTECTED]>
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.
>
> I think there is no such possibility in Apache. It terminates
> processes or thread after every request.

Sorry, that it is not generally true. It depends on the hosting
mechanism and how it has been configured.

If using mod_python or mod_wsgi, then Apache processes which hold
Django instance will normally persist for many requests. They will not
be terminate after every request.

The problem with mod_python and mod_wsgi (embedded mode) is that they
are multi process on UNIX and so you have to contend with there being
multiple copies in memory and thus multiple instances of that
background task as well. It may be a problem if multiple process try
to run background task at same time.

If using mod_wsgi daemon mode, then you can setup there to be only one
process for the application and so only one instance of background
task. If that task has to be run when idle, just need to be careful
what you are doing with idle timeout restarts and possibly have
preloading of Django setup as well.

If using fastcgi, it also can be configured to have single or multiple
processes and also believe it can be configured to kill off processes
when idle for a period. As to original posters problem, it may be case
the web hosting has configured it to kill off idle processes or simply
recycle them every so often to avoid problems with memory creep.

In other words, it is not as simple as you think. The only instance
where you are guaranteed for process to be killed after every request
is CGI.

Graham

> >  Are there any web pages or documentation people could point me to
> > which explain how to set this up?  Again I'd like my Django app to run
> > continuously and have each web request make a call into an already
> > running python interpreter.
>
> Maybe you can use cron job to run or make request to you application
> periodically. Drupal uses such thing to index web pages and some other
> stuffs.
>
> --
> Regards
> Dulmandakh
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to