def __init__(self, auth, addr, timeout=None): s_neuron.CellUser.__init__(self, auth) self._cryo_sess = self.open(addr, timeout=timeout) if self._cryo_sess is None: raise s_common.HitMaxTime(timeout=timeout)
def sync(self, job, timeout=None): ''' Wait and return the value for the job. ''' if not self.wait(job[0], timeout=timeout): raise s_common.HitMaxTime(timeout) return jobret(job)
def _waitTeleJob(self, job, timeout=None): # dont block the consumer thread, consume events # until the job completes... if threading.currentThread() == self._tele_cthr: return self._fakeConsWait(job, timeout=timeout) if not self._tele_boss.wait(job[0], timeout=timeout): raise s_common.HitMaxTime()
def _fakeConsWait(self, job, timeout=None): # a wait like function for the consumer thread # which continues to consume events until a job # has been completed. maxtime = None if timeout is not None: maxtime = time.time() + timeout while not job[1].get('done'): if maxtime is not None and time.time() >= maxtime: raise s_common.HitMaxTime() mesg = self._tele_q.get() self.dist(mesg)