def __call__(self, *a): self.n = self.n + 1 try: next = self.iter.next() except StopIteration: log.debug('stop iteration, calling success: %r', funcinfo(self.callback.success)) self.callback.success() else: log.debug('%s #%d: %r', funcinfo(self.callback), self.n, funcinfo(next)) next(**dict(success = self, error = self.callback.error))
def __call__(self, *a): self.n = self.n + 1 try: next = self.iter.next() except StopIteration: log.debug('stop iteration, calling success: %r', funcinfo(self.callback.success)) self.callback.success() else: log.debug('%s #%d: %r', funcinfo(self.callback), self.n, funcinfo(next)) next(**dict(success=self, error=self.callback.error))
def __init__(self, cb, threadname=None): assert callable(cb) self.threadname = threadname or threading.currentThread().getName() if self.threadname not in call_laters: try: cb_dbg_str = ', '. join(str(s) for s in [funcinfo(cb), cb.func_code.co_filename, cb.func_code.co_firstlineno]) except Exception: cb_dbg_str = 'Error making debug string. Repr is: {%s}' % funcinfo(cb) if cb is not DO_NOTHING: pass # log.warning("WARNING: %s is supposed to be called later, but thread %s does not have a call later mechanism!", # cb_dbg_str, self.threadname) self.cb = cb
def __call__(self, *a, **k): if threading.currentThread().getName() != self.threadname \ and self.threadname in call_laters: try: return call_laters[self.threadname](lambda: self.cb(*a, **k)) except Exception: print >> sys.stderr, "callback is %s" % funcinfo(self.cb) raise else: try: return self.cb(*a, **k) except Exception: print >>sys.stderr, '%s in %s (%s). args/kwargs are: %r,%r' % (getattr(self.cb, '__name__', funcinfo(self.cb)), self.cb.__module__, funcinfo(self.cb), a,k) raise
def __call__(self, *a, **k): if threading.currentThread().getName() != self.threadname \ and self.threadname in call_laters: try: return call_laters[self.threadname](lambda: self.cb(*a, **k)) except Exception: print >> sys.stderr, "callback is %s" % funcinfo(self.cb) raise else: try: return self.cb(*a, **k) except Exception: print >> sys.stderr, '%s in %s (%s). args/kwargs are: %r,%r' % ( getattr(self.cb, '__name__', funcinfo( self.cb)), self.cb.__module__, funcinfo(self.cb), a, k) raise
def __init__(self, cb, threadname=None): assert callable(cb) self.threadname = threadname or threading.currentThread().getName() if self.threadname not in call_laters: try: cb_dbg_str = ', '.join( str(s) for s in [ funcinfo(cb), cb.func_code.co_filename, cb.func_code.co_firstlineno ]) except Exception: cb_dbg_str = 'Error making debug string. Repr is: {%s}' % funcinfo( cb) if cb is not DO_NOTHING: pass # log.warning("WARNING: %s is supposed to be called later, but thread %s does not have a call later mechanism!", # cb_dbg_str, self.threadname) self.cb = cb
def __repr__(self): return '<%s %s>' % (type(self).__name__, funcinfo(self.cb))