Re: Django and daemon?

2006-05-31 Thread spacedman


DavidA wrote:

> An alternative that stays inside Django is to setup a trigger in cron
> (or NT's Task Scheduler) that gets a URL every few minutes and the view
> code for that URL does the email processing you mention. You avoid
> creating a true daemon/service just by "waking" up periodically and
> doing any work that needs to be done.

 This is simple if the view doesn't need any authentication, but you'd
have to login and muck with session cookies if the view is protected by
some access rights. Python's cookielib might help here, or if you are
writing it in shell, use wget with its various cookie options, and use
its --post-* options to send the login form response.

Probably simpler to write a python script that imports django and runs
on the server!

Barry


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django and daemon?

2006-05-31 Thread Wade Leftwich

DavidA wrote:
> 
> Russell Blau wrote:
> 
>>Ahh, thanks, it always helps to take the blinders off.  The only downside is
>>that I have to learn how to use yet another software package.  ;-)
> 
> 
> An alternative that stays inside Django is to setup a trigger in cron
> (or NT's Task Scheduler) that gets a URL every few minutes and the view
> code for that URL does the email processing you mention. You avoid
> creating a true daemon/service just by "waking" up periodically and
> doing any work that needs to be done.
> 
> I use this technique for a scheduled task application written in
> Django. It works well, avoids the threading issues, and in my case is
> good enough for the problem at hand.
> 

This is a commonly used pattern in the Zope world (where I'm coming
from). An advantage to doing it like this is that you can run your
cronjob on a different box.

-- Wade Leftwich
Ithaca, NY

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django and daemon?

2006-05-31 Thread DavidA


Russell Blau wrote:
> Ahh, thanks, it always helps to take the blinders off.  The only downside is
> that I have to learn how to use yet another software package.  ;-)

An alternative that stays inside Django is to setup a trigger in cron
(or NT's Task Scheduler) that gets a URL every few minutes and the view
code for that URL does the email processing you mention. You avoid
creating a true daemon/service just by "waking" up periodically and
doing any work that needs to be done.

I use this technique for a scheduled task application written in
Django. It works well, avoids the threading issues, and in my case is
good enough for the problem at hand.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django and daemon?

2006-05-30 Thread Russell Blau

"spacedman" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> Wouldn't it be better to setup 'procmail' to process incoming emails as
> they arrive. Then your procmail script could update the database.

Ahh, thanks, it always helps to take the blinders off.  The only downside is 
that I have to learn how to use yet another software package.  ;-)

Seriously, thanks for the good suggestion.





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django and daemon?

2006-05-30 Thread spacedman

Wouldn't it be better to setup 'procmail' to process incoming emails as
they arrive. Then your procmail script could update the database. As
long as you are using a decent database server (*cough*POSTGRES*cough*)
then concurrency shouldnt be a problem.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Django and daemon?

2006-05-30 Thread Russell Blau

I'm kind of a newbie at this (web applications, that is, not Python
programming), so I'd appreciate any advice others can offer.

I'm developing a Django app (post-M-R) that will communicate by email with
some remote hosts (which are running archaic software that can't easily be
updated to use some more modern form of communication), and then take
information from the emails and insert it into the database.  I can handle
writing a Thread class that will poll the inbox periodically and process
each of the messages it finds to create and save the appropriate model
objects to the database.

My question is, how can I launch this background daemon process so that I
can be reasonably sure that there will always be one and only one instance
of it running at any given time?  I don't see any obvious "hook" in the
Django code for running something when the server is first started up.  It
seems to me that modules like models.py, views.py etc. get imported multiple
times so that there would be too many threads running if I tried to put it
in one of these modules.

Is this something that needs to be done within the webserver?  If so, how?
(I'm using the Django dev server for now but plan to switch to Apache for
production.) And I also need some "hook" that will let me restart the daemon
if it has crashed for some reason...

Thanks in advance for any suggestions.

Russ Blau




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---