On Mar 26, 7:58 pm, shabda <[EMAIL PROTECTED]> wrote: > I response to some urls, my views need to start some potentially time > taking actions. So how can I start background process, would it be as > simple as > > ... > t = threading.Thread(...) > t.setDaemon(True) > t.start() > return HttpResponse(..) > > Or does django/apache have limitation on how threading can be used? > Would my thread be killed, once the response is sent back?
You are much much better off having a back end process which embeds a mini HTTP server set up to respond to XML-RPC requests. The Apache/ Django processes can then make an XML-RPC request to the long running persistent back end process which then does the work in a separate thread, via some form of queuing mechanism and thread pooling mechanism as needs be to keep number of active threads down, or using other means as appropriate. Being in a single back end process, you can then also support XML-RPC requests to check on status of jobs being done, cancel jobs etc etc. You also don't then have to deal with the fact that Apache is multiprocess and subsequent requests may not come back to the same process if something needs to query outcome of job. You also don't have to deal with possibility of Apache killing off one its processes, which might contain running jobs, when it is recycling its processes. Graham --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---