Hi all,<br>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.<br>
<br>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.<br>
<br>My method is start it when you first use it, see the snip following:<br><br>===============<br>class AsyncTool( UniqueObject, SimpleItem, ActionProviderBase ):<br> ...<br> def addJob( self, *args ):<br> ''' '''<br>
self._startZCAsync()<br> <br> portal = getToolByName(self,'portal_url').getPortalObject()<br> <br> # get queue from portal root<br> queue = zc.async.interfaces.IQueue( portal )<br>
<br> # insert a job<br> job = queue.put( Job(...) )<br><br> def _startZCAsync( self ):<br> # create volatile attributes<br> if not hasattr( self, '_v_start_zcasync' ):<br> self._v_start_zcasync = 0<br>
<br> if not self._v_start_zcasync:<br> db = Zope2.DB<br> <br> # zc.async does not startup, start it now<br> zc.async.configure.base()<br> zc.async.configure.start( db, poll_interval=1, twisted=False )<br>
<br> self._v_start_zcasync = 1<br>===============<br><br>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.<br>
<br>So I want to know the right time to start zc.async dispatcher in Zope2?<br><br>best regards<br>eastxing<br>