[Zope] question about use zc.async in Zope2
eastxing
eastxing at gmail.com
Sat Mar 7 04:34:06 EST 2009
Hi all,
In Plone2.5.5(with Zope2.9.6-final) I use zasync as my schedule task
framework, it works well. Then I update my site to Plone3.1.7, and go
further update to use Zope2.11.2 and ZODB3.9.0. Now I want to replace zasync
with zc.async.
As I know in Zope3 there is a event 'zope.app.appsetup.IDatabaseOpenedEvent'
that you can subscribe to start your zc.async dispatcher. But in Zope2.11.2,
the event never be fired, so I have to find other point to start the
dispatcher.
My method is start it when you first use it, see the snip following:
===============
class AsyncTool( UniqueObject, SimpleItem, ActionProviderBase ):
...
def addJob( self, *args ):
''' '''
self._startZCAsync()
portal = getToolByName(self,'portal_url').getPortalObject()
# get queue from portal root
queue = zc.async.interfaces.IQueue( portal )
# insert a job
job = queue.put( Job(...) )
def _startZCAsync( self ):
# create volatile attributes
if not hasattr( self, '_v_start_zcasync' ):
self._v_start_zcasync = 0
if not self._v_start_zcasync:
db = Zope2.DB
# zc.async does not startup, start it now
zc.async.configure.base()
zc.async.configure.start( db, poll_interval=1, twisted=False )
self._v_start_zcasync = 1
===============
It works, but fragile. Any of my jobs execute failure will cause the
'volatile' attribute '_v_start_zcasync' lost, and dispatcher start process
will run again, this cause error.
So I want to know the right time to start zc.async dispatcher in Zope2?
best regards
eastxing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20090307/c1b049cb/attachment.html
More information about the Zope
mailing list