def getworker(cls): with cls._worker_lock: if cls._worker is not None: return cls._worker import devsup.hooks T = Worker(max=cls.queuelength) devsup.hooks.addHook('AtIocExit', T.join) T.start() cls._worker = T return T
def __init__(self, name): super(UnitWorker,self).__init__() self.name = name self.scan = IOScanListThread() self.scan.force = 0 self.worker = Worker() addHook('AfterIocRunning', self.worker.start) addHook('AtIocExit', self.worker.join)
def __init__(self, rec, link): self.rec, self.link = rec, link if self.worker is None: from devsup.util import Worker self.worker = Worker(max=1) @initHook('AtIocExit') def _exit(): print 'stop worker for', rec.NAME self.worker.join() self.worker.start() assert self.worker is not None, "Offload requires a worker thread" I = [] for fld, name in self.inputs.items(): F = rec.field(fld) I.append((fld, name, F.fieldinfo()[2] != 1)) O = list(self.outputs.items()) self._inputs, self._outputs = I, O