Changeset 116
- Timestamp:
- 12/04/07 01:14:12 (1 year ago)
- Files:
-
- projects/AsynQueue/trunk/asynqueue/jobs.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/AsynQueue/trunk/asynqueue/jobs.py
r112 r116 26 26 from twisted.internet import defer, reactor 27 27 from twisted.python.failure import Failure 28 from twisted.python .reflect import namedObject28 from twisted.python import reflect 29 29 from twisted.spread import pb, flavors 30 30 … … 72 72 def remote_registerClasses(self, *args): 73 73 """ 74 Instructs my broker to register the classes specified by the argument(s). 75 76 The classes will be registered for B{all} jobs, and are specified by their 77 string representations:: 74 Instructs my broker to register the classes specified by the 75 argument(s). 76 77 The classes will be registered for B{all} jobs, and are specified by 78 their string representations:: 78 79 79 80 <package(s).module.class> 80 81 81 82 """ 83 modules = [] 82 84 for stringRep in args: 83 85 # Load the class for the string representation 84 cls = namedObject(stringRep)86 cls = reflect.namedObject(stringRep) 85 87 # Register instances of the class, including its type and module 86 88 pb.setUnjellyableForClass(stringRep, cls) 87 89 if cls.__module__ not in modules: 90 modules.append(cls.__module__) 91 # Try to reload the modules for the classes in case they've changed 92 # since the last run 93 for module in modules: 94 try: 95 reload(reflect.namedModule(module)) 96 except: 97 pass 98 88 99 def remote_newJob(self, jobID, jobCode): 89 100 """ … … 136 147 % (callName, jobID))) 137 148 149 def remote_forgetJob(self, jobID): 150 """ 151 Call this with the I{jobID} of a job that is done and I will forget its 152 namespace, thus freeing up memory. 153 """ 154 if jobID in self.jobs: 155 del self.jobs[jobID] 156 138 157 def remote_exit(self, stopReactor=False): 139 158 """ … … 414 433 def jobRan(result): 415 434 status, result = result 416 if status: 417 del self.callsPending[jobID][d] 418 d.callback(result) 435 if status and jobID in self.callsPending: 436 if d in self.callsPending[jobID]: 437 del self.callsPending[jobID][d] 438 d.callback(result) 419 439 else: 420 440 log("Error running job %d:\n%s", jobID, result) … … 453 473 self.updates.pop(jobID, None) 454 474 self.callsPending.pop(jobID, None) 475 dList = [ 476 worker.remoteCaller('forgetJob', jobID) 477 for worker in self.queue.workers()] 478 return defer.DeferredList(dList)
