async def anit(cls, *args, **kwargs): # sneak in a quick loop check here for convenience if s_glob._glob_loop is None: s_glob.initloop() self = cls() try: await self.__anit__(*args, **kwargs) except (asyncio.CancelledError, Exception): if self.anitted: await self.fini() raise try: await self.postAnit() except (asyncio.CancelledError, Exception): logger.exception('Error during postAnit callback.') await self.fini() raise return self
async def anit(cls, *args, **kwargs): # sneak in a quick loop check here for convenience if s_glob._glob_loop is None: s_glob.initloop() self = cls() try: await self.__anit__(*args, **kwargs) except Exception: if self.anitted: await self.fini() raise return self
def get(self): ''' Pending retrieve on the queue ''' while not self.isfini: try: val = self.deq.popleft() break except IndexError: self.notemptyevent.clear() if len(self.deq): continue self.notemptyevent.wait() else: return None if not self.notdrainingevent.is_set(): if len(self.deq) < self.drain_level: s_glob.initloop().call_soon_threadsafe( self.notdrainingevent.set) return val