[Checkins] SVN: lovely.remotetask/trunk/src/lovely/remotetask/ Now the job id is passed to the task during execution. Now the task

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Aug 18 05:29:23 EDT 2006


Log message for revision 69634:
  Now the job id is passed to the task during execution. Now the task 
  knows everything during execution and it is up to the task 
  implementation to use or not to use the info.
  
   --This line, and those below, will be ignored--
  
  M    service.py
  M    task.py
  M    interfaces.py
  M    README.txt
  

Changed:
  U   lovely.remotetask/trunk/src/lovely/remotetask/README.txt
  U   lovely.remotetask/trunk/src/lovely/remotetask/interfaces.py
  U   lovely.remotetask/trunk/src/lovely/remotetask/service.py
  U   lovely.remotetask/trunk/src/lovely/remotetask/task.py

-=-
Modified: lovely.remotetask/trunk/src/lovely/remotetask/README.txt
===================================================================
--- lovely.remotetask/trunk/src/lovely/remotetask/README.txt	2006-08-18 09:22:02 UTC (rev 69633)
+++ lovely.remotetask/trunk/src/lovely/remotetask/README.txt	2006-08-18 09:29:22 UTC (rev 69634)
@@ -36,7 +36,7 @@
 The only API requirement on the converter is to be callable. Now we make sure
 that the task works:
 
-  >>> echoTask(service, input={'foo': 'blah'})
+  >>> echoTask(service, 1, input={'foo': 'blah'})
   {'foo': 'blah'}
 
 Let's now register the task as a utility:

Modified: lovely.remotetask/trunk/src/lovely/remotetask/interfaces.py
===================================================================
--- lovely.remotetask/trunk/src/lovely/remotetask/interfaces.py	2006-08-18 09:22:02 UTC (rev 69633)
+++ lovely.remotetask/trunk/src/lovely/remotetask/interfaces.py	2006-08-18 09:29:22 UTC (rev 69634)
@@ -97,14 +97,18 @@
         schema=zope.interface.Interface,
         required=False)
 
-    def __call__(self, service, input):
+    def __call__(self, service, jobid, input):
         """Execute the task.
 
-        The service argument is the task service object. It allows access to
+        The ``service`` argument is the task service object. It allows access to
         service wide data and the system as a whole.
 
-        The input object must conform to the input schema (if specified). The
-        return value must conform to the output schema.
+        Tasks do not live in a vacuum, but are tightly coupled to the job
+        executing it. The ``jobid`` argument provides the id of the job being
+        processed.
+
+        The ``input`` object must conform to the input schema (if
+        specified). The return value must conform to the output schema.
         """
 
 

Modified: lovely.remotetask/trunk/src/lovely/remotetask/service.py
===================================================================
--- lovely.remotetask/trunk/src/lovely/remotetask/service.py	2006-08-18 09:22:02 UTC (rev 69633)
+++ lovely.remotetask/trunk/src/lovely/remotetask/service.py	2006-08-18 09:29:22 UTC (rev 69634)
@@ -121,7 +121,7 @@
             self.taskInterface, name=job.task)
         job.started = datetime.datetime.now()
         try:
-            job.output = jobtask(self, job.input)
+            job.output = jobtask(self, job.id, job.input)
             job.status = interfaces.COMPLETED
         except task.TaskError, error:
             job.error = error
@@ -163,4 +163,4 @@
             time.sleep(1)
         except:
             # This thread should never crash, thus a blank except
-            pass
\ No newline at end of file
+            pass

Modified: lovely.remotetask/trunk/src/lovely/remotetask/task.py
===================================================================
--- lovely.remotetask/trunk/src/lovely/remotetask/task.py	2006-08-18 09:22:02 UTC (rev 69633)
+++ lovely.remotetask/trunk/src/lovely/remotetask/task.py	2006-08-18 09:29:22 UTC (rev 69634)
@@ -35,7 +35,7 @@
     def __init__(self, func):
         self.func = func
 
-    def __call__(self, service, input):
+    def __call__(self, service, jobid, input):
         return self.func(input)
 
     def __repr__(self):



More information about the Checkins mailing list