[Checkins] SVN: Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/ remove reference to _p_jar

Jean-Francois Roche jfroche at jfroche.be
Mon Oct 18 10:33:24 EDT 2010


Log message for revision 117717:
  remove reference to _p_jar
  fix test after change to use z2 processor
  

Changed:
  U   Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/startup.py
  U   Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/tests/processor.txt

-=-
Modified: Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/startup.py
===================================================================
--- Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/startup.py	2010-10-18 14:33:00 UTC (rev 117716)
+++ Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/startup.py	2010-10-18 14:33:23 UTC (rev 117717)
@@ -4,22 +4,17 @@
 
 from z3c.taskqueue.startup import getRootFolder
 from z3c.taskqueue.startup import getStartSpecifications
-from z3c.taskqueue.startup import startOneService
+from z3c.taskqueue.startup import startOneService, storeDBReference
 
 log = logging.getLogger('five.taskqueue')
 
 
-def databaseOpened(event):
-    """Start the queue processing services based on the
-       settings in zope.conf"""
-    log.info('handling event IDatabaseOpenedEvent')
-
-    root_folder = getRootFolder(event)
-
+def startServices(root_folder):
     configuration = getTaskqueueConfiguration()
     startSpecifications = getStartSpecifications(configuration)
 
     for siteName, serviceName in startSpecifications:
+        log.debug('Starting service %s from site %s' % (serviceName, siteName))
         site = getSite(siteName, root_folder)
         if site is None:
             continue
@@ -27,8 +22,19 @@
         if not started:
             msg = 'service %s from site %s was not started.'
             log.warn(msg % (serviceName, siteName))
+        else:
+            log.debug('Service %s from site %s started.' % (serviceName, siteName))
 
 
+def databaseOpened(event):
+    """Start the queue processing services based on the
+       settings in zope.conf"""
+    log.info('handling event IDatabaseOpenedEvent')
+    storeDBReference(event)
+    root_folder = getRootFolder(event)
+    startServices(root_folder)
+
+
 def getSite(siteName, root_folder):
     try:
         site = root_folder._getOb(siteName)

Modified: Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/tests/processor.txt
===================================================================
--- Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/tests/processor.txt	2010-10-18 14:33:00 UTC (rev 117716)
+++ Sandbox/gotcha/five.taskqueue/trunk/src/five/taskqueue/tests/processor.txt	2010-10-18 14:33:23 UTC (rev 117717)
@@ -44,6 +44,9 @@
 
   >>> import zope.component
   >>> zope.component.provideUtility(sleepTask, name='sleep')
+  >>> import Zope2
+  >>> from z3c.taskqueue.startup import storeDBReference
+  >>> storeDBReference(Zope2.DB)
 
 
 The Simple Processor
@@ -67,8 +70,10 @@
 processor constructor is the database and the second the traversal stack to
 the task service. All other arguments are optional:
 
+  >>> import z3c.taskqueue
+  >>> db = z3c.taskqueue.GLOBALDB
   >>> proc = processor.SimpleProcessor(
-  ...     tasks._p_jar.db(), tasks.getServicePath(), waitTime=0.0)
+  ...     db, tasks.getServicePath(), waitTime=0.0)
 
 Let's now process the first job. We clear the log.
 
@@ -108,7 +113,7 @@
   z3c.taskqueue INFO
     Job: 1
   z3c.taskqueue INFO
-    starting service remotetasks.tasks.tasks
+    starting service tasks
   z3c.taskqueue INFO
     Job: 2
   z3c.taskqueue INFO
@@ -116,7 +121,7 @@
   z3c.taskqueue INFO
     Job: 4
   z3c.taskqueue INFO
-    stopping service remotetasks.tasks.tasks
+    stopping service tasks
 
 Transactions in jobs
 --------------------
@@ -176,8 +181,9 @@
 Before testing the processor in the task service, let's have a look at every
 method by itself. So we instantiate the processor:
 
+  >>> db = z3c.taskqueue.GLOBALDB
   >>> proc = processor.MultiProcessor(
-  ...     tasks._p_jar.db(), tasks.getServicePath(), waitTime=0)
+  ...     db, tasks.getServicePath(), waitTime=0)
 
 The maximum amount of threads can be set as well:
 
@@ -242,7 +248,7 @@
 
   >>> print log_info
   z3c.taskqueue INFO
-    starting service remotetasks.tasks.tasks
+    starting service tasks
   z3c.taskqueue INFO
     Job: 3
   z3c.taskqueue INFO
@@ -250,7 +256,7 @@
   z3c.taskqueue INFO
     Job: 2
   z3c.taskqueue INFO
-    stopping service remotetasks.tasks.tasks
+    stopping service tasks
 
 
 Let's now set the thread limit to two and construct a new set of tasks that
@@ -280,7 +286,7 @@
 
   >>> print log_info
   z3c.taskqueue INFO
-    starting service remotetasks.tasks.tasks
+    starting service tasks
   z3c.taskqueue INFO
     Job: 1
   z3c.taskqueue INFO
@@ -290,7 +296,7 @@
   z3c.taskqueue INFO
     Job: 4
   z3c.taskqueue INFO
-    stopping service remotetasks.tasks.tasks
+    stopping service tasks
 
   >>> print conflict_logger
 



More information about the checkins mailing list