Maciej Wisniowski wrote:
I want to use lovely.remotetask in Z3 application.
Use case is very simple:
User views page, this causes long running function to be started
and Ajax calls from the page check every second if there is a result.
1. content object (Folderish) with instance of remotetask.TaskService()
called 'monitor_service' inside
2. mytask = remotetask.task.SimpleTask(myLongRunningFunction)
3. named utility for 'mytask'
The question is how should I start and stop remotetask jobs?
Currently, when user enters a page I call (every time):
jobid = self['monitor_service'].add(u'mytask', appdict)
Then ajax is repeadetly checking for result and when
status is Completed I call
It works nice, but after looking into service.py code I see
it will break when I'll have few concurrent users.
Seems that I should call startProcessing() on zope startup
and stopProcessing on zope shutdown?
For startup do this :
"""Start the amazon remotetask on startup."""
db = event.database
connection = db.open()
root = connection.root()
root_folder = root.get(ZopePublication.root_name, None)
for site in root_folder.values():
service = component.queryUtility(
if service is not None:
if not service.isProcessing():
I assume here that the remote tasks are located in one of the site
directly contained in root.
For shutdown :
I have no solution for this right now.
Zope3-users mailing list