def get(self, waiting=True, timeout=None): if self.inp: val = self.inp.popleft() sleep() return val mark = None if waiting: kw = dict(waits=[self]) if timeout: kw['sleep'] = timeout mark, val = first(**kw) if mark == self: return val else: raise QueueTimeout() raise QueueEmpty()
def client_conn_handler(self, addr): '''The default connection handler. Handles @call-ing behavior to client API methods. ''' from diesel.core import sleep, ConnectionClosed yield self.on_connect() while True: try: if not self.jobs: yield sleep() if not self.jobs: continue mygen = self.jobs.popleft() yield mygen except ConnectionClosed: self.close() self.on_close() break