[Checkins] SVN: zc.async/trunk/src/zc/async/job. remove obsolete retry process for success/failure callbacks: it is now handled by retry policies

Gary Poster gary at zope.com
Tue Jun 24 17:10:10 EDT 2008


Log message for revision 87717:
  remove obsolete retry process for success/failure callbacks: it is now handled by retry policies

Changed:
  U   zc.async/trunk/src/zc/async/job.py
  U   zc.async/trunk/src/zc/async/job.txt

-=-
Modified: zc.async/trunk/src/zc/async/job.py
===================================================================
--- zc.async/trunk/src/zc/async/job.py	2008-06-24 21:07:16 UTC (rev 87716)
+++ zc.async/trunk/src/zc/async/job.py	2008-06-24 21:10:09 UTC (rev 87717)
@@ -66,17 +66,6 @@
         return res
     return callable(res)
 
-def completeStartedJobArguments(job, result):
-    if isinstance(result, twisted.python.failure.Failure):
-        for collection in (job.args, job.kwargs.values()):
-            for a in collection:
-                if zc.async.interfaces.IJob.providedBy(a):
-                    status = a.status
-                    if status == zc.async.interfaces.ACTIVE:
-                        a.fail()
-                    elif status == zc.async.interfaces.CALLBACKS:
-                        a.resumeCallbacks()
-
 class RetryCommonFourTimes(persistent.Persistent): # default
     zope.component.adapts(zc.async.interfaces.IJob)
     zope.interface.implements(zc.async.interfaces.IRetryPolicy)
@@ -407,13 +396,6 @@
             if failure is not None:
                 failure.parent = res
             self.addCallback(res)
-            # we need to handle the case of callbacks on the internal success/
-            # failure jobs, to be safe.
-            abort_handler = zc.async.interfaces.IJob(
-                completeStartedJobArguments)
-            abort_handler.args.append(res)
-            res.addCallback(
-                abort_handler, failure_log_level, retry_policy_factory)
         else:
             res = self
         return res

Modified: zc.async/trunk/src/zc/async/job.txt
===================================================================
--- zc.async/trunk/src/zc/async/job.txt	2008-06-24 21:07:16 UTC (rev 87716)
+++ zc.async/trunk/src/zc/async/job.txt	2008-06-24 21:10:09 UTC (rev 87717)
@@ -1566,21 +1566,14 @@
     1
 
 When you use ``addCallbacks``, the job you get back has a callable with
-the success and failure jobs you passed in as arguments.  Moreover, the
-job you get back already has a callback, for safety reasons.  If a
-dispatcher dies while the job is in progress, active argument jobs
-should be cleaned up and will not be cleaned up automatically with the
-logic in ``resumeCallbacks`` (by design: this may not be desired behavior
-in all cases).  Therefore we add a callback to the main callback that
-does this job.
+the success and failure jobs you passed in as arguments.
 
     >>> j.callbacks[0] is j_callback
     True
-    >>> len(j_callback.callbacks)
-    1
+    >>> j_callback.args # doctest: +ELLIPSIS
+    [<zc.async.job.Job ... ``zc.async.doctest_test.multiply(5)``>, None]
 
-``addCallback`` does not have this characteristic (you are responsible for any
-internal jobs, therefore).
+``addCallback`` does not have this characteristic.
 
     >>> j_callback2 = zc.async.job.Job(multiply, 9)
     >>> j_callback2 is j.addCallback(j_callback2)
@@ -1768,11 +1761,10 @@
     >>> print r.getMessage() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
     starting callback
      <...Job (oid ..., db 'unnamed')
-      ``...completeStartedJobArguments(...Job (oid ..., db 'unnamed'))``>
-    to
-     <...Job (oid ..., db 'unnamed')
       ``...success_or_failure(...Job (oid ..., db 'unnamed'),
                               ...Job (oid ..., db 'unnamed'))``>
+    to
+     <...Job (oid ..., db 'unnamed') ``...multiply(5, 3)``>
 
 
     As with all job calls, the results are logged.
@@ -1785,8 +1777,7 @@
     ...
     >>> print r.getMessage() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
     <zc.async.job.Job (oid ..., db 'unnamed')
-     ``zc.async.job.completeStartedJobArguments(zc.async.job.Job
-                                                (oid ..., db 'unnamed'))``>
+     ``zc.async.job.success_or_failure(...)``>
     succeeded with result:
     None
 
@@ -1802,8 +1793,7 @@
     ...
     >>> print r.getMessage() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
     <zc.async.job.Job (oid ..., db 'unnamed')
-     ``zc.async.job.completeStartedJobArguments(zc.async.job.Job
-                                                (oid ..., db 'unnamed'))``>
+     ``zc.async.job.success_or_failure(...)``>
     succeeded with result:
     None
 



More information about the Checkins mailing list