[Checkins] SVN: Sandbox/gotcha/five.taskqueue/src/five/taskqueue/ MultiProcessor tests do pass
Godefroid Chapelle
gotcha at bubblenet.be
Wed Apr 14 06:26:59 EDT 2010
Log message for revision 110848:
MultiProcessor tests do pass
Changed:
U Sandbox/gotcha/five.taskqueue/src/five/taskqueue/processor.py
U Sandbox/gotcha/five.taskqueue/src/five/taskqueue/tests/processor.txt
-=-
Modified: Sandbox/gotcha/five.taskqueue/src/five/taskqueue/processor.py
===================================================================
--- Sandbox/gotcha/five.taskqueue/src/five/taskqueue/processor.py 2010-04-14 10:23:35 UTC (rev 110847)
+++ Sandbox/gotcha/five.taskqueue/src/five/taskqueue/processor.py 2010-04-14 10:26:59 UTC (rev 110848)
@@ -5,6 +5,7 @@
import ZPublisher
from z3c.taskqueue.processor import BaseSimpleProcessor
+from z3c.taskqueue.processor import BaseMultiProcessor
from z3c.taskqueue.processor import ERROR_MARKER
log = logging.getLogger('z3c.taskqueue')
@@ -26,6 +27,7 @@
'SERVER_PORT': '8080',
'PATH_INFO': '/' + '/'.join(path)}
request = HTTPRequest(None, env, response)
+ request.args = args
conn = self.db.open()
root = conn.root()
request['PARENTS'] = [root['Application']]
@@ -45,3 +47,7 @@
class SimpleProcessor(Z2PublisherMixin, BaseSimpleProcessor):
""" SimpleProcessor for Zope2 """
+
+
+class MultiProcessor(Z2PublisherMixin, BaseMultiProcessor):
+ """ SimpleProcessor for Zope2 """
Modified: Sandbox/gotcha/five.taskqueue/src/five/taskqueue/tests/processor.txt
===================================================================
--- Sandbox/gotcha/five.taskqueue/src/five/taskqueue/tests/processor.txt 2010-04-14 10:23:35 UTC (rev 110847)
+++ Sandbox/gotcha/five.taskqueue/src/five/taskqueue/tests/processor.txt 2010-04-14 10:26:59 UTC (rev 110848)
@@ -160,10 +160,17 @@
Let's add a few new tasks to execute:
- >>> jobid = tasks.add(u'sleep', (0.04, 1))
+ >>> jobid_1 = tasks.add(u'sleep', (0.04, 1))
+
>>> jobid = tasks.add(u'sleep', (0.18, 2))
+ >>> jobid == jobid_1 + 1
+ True
>>> jobid = tasks.add(u'sleep', (0, 3))
+ >>> jobid == jobid_1 + 2
+ True
>>> jobid = tasks.add(u'sleep', (0.02, 4))
+ >>> jobid == jobid_1 + 3
+ True
>>> transaction.commit()
Before testing the processor in the task service, let's have a look at every
@@ -191,15 +198,15 @@
>>> proc.hasJobsWaiting()
True
-Once you know that jobs are available, you can claim a job:
+Once you know that jobs are available, you can claim a job.
+We need to explicitely claim a job before executing it, to ensure it is markes
+as claimed: this avoids that another thread picks up the job.
>>> jobid = proc.claimNextJob()
- >>> jobid
- 1392637180
+ >>> jobid == jobid_1
+ True
-We need to claim a job before executing it, so that the database marks the job
-as claimed and no new thread picks up the job. Once we claimed a particular
-job, we can process it:
+Once we claimed a particular job, we can process it:
>>> log_info.clear()
@@ -292,7 +299,8 @@
bit to give the thread a chance to start up. This waiting time is defined by a
module global:
- >>> processor.THREAD_STARTUP_WAIT
+ >>> import z3c.taskqueue
+ >>> z3c.taskqueue.processor.THREAD_STARTUP_WAIT
0.050000000000000003
On my machine this number seems to work well. On slower machines you might
More information about the checkins
mailing list