On Wed, 2006-07-05 at 23:39 -0700, Tyson Tate wrote:
> In one of my Django projects, I use the dispatcher and signals to  
> notify various apps that the front page has been viewed. Some of  
> these apps run a method on the raising of this signal to see if it's  
> been more than X minutes since the last time the method has been run.  
> If the method was run over X minutes ago, it calls another method  
> which calls on various API services on the internet (flickr,  
> Ma.gnolia, etc) and synchronizes some of my database tables with  
> random junk.
> 
> Sometimes, the API calls can take some time (Ma.gnolia, I'm talking  
> to you!), which ends up making the user visiting my front page wait  
> until all the API calls are done running before the front page loads.
> 
> Is there a way to avoid this by executing the synchronization methods  
> in another thread or by somehow backgrounding them?

You could fork/exec another process and make it a session group leader
(basically make it a daemon process) so that it is not dependent on the
lifetime of its parent. That should work fairly smoothly.

This sort of problem is why, when you brought this solution up last
month, a couple of us were still recommending doing this with cron or
some other system-level process, rather than hooking it into Django: a
transient process for handling a web request is not really a nice place
to be doing long-running periodic tasks. 

Malcolm



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to