def asyncPipeForever(): """A source that returns a Deferred infinite generator of items. Loopable. Returns ------- _OUTPUT : twisted.internet.defer.Deferred generator of items """ return asyncReturn(forever)
def asyncGetSplits(_INPUT, pieces=None, funcs=None, **kwargs): _input = yield _INPUT finitize = kwargs.pop('finitize', False) dictize = kwargs.pop('dictize', False) # asyncDict = partial(maybeDeferred, DotDict) # inputs = yield asyncCmap(asyncDict, _input) finite = utils.finitize(_input) if finitize and _input else _input funcs = funcs or get_async_broadcast_funcs(pieces, **kwargs) inputs = imap(DotDict, finite) if finite and dictize else finite if inputs: result = yield asyncBroadcast(inputs, *funcs) else: result = yield asyncReturn(funcs) returnValue(result)
def asyncParseResult(rules, word, _pass): # asyncSubstitute = coopReduce(func, rules, word) asyncSubstitute = asyncReduce(partial(maybeDeferred, func), rules, word) return asyncReturn(word) if _pass else asyncSubstitute
def asyncParseResult(rules, word, _pass): # return asyncReturn(word) if _pass else coopReduce(func, rules, word) asyncFunc = partial(maybeDeferred, func) return asyncReturn(word) if _pass else asyncReduce(asyncFunc, rules, word)
def asyncGetRateData(): make_cache_key = utils.cache._memoize_make_cache_key(timeout=utils.timeout) cached = utils.cache.get(make_cache_key(get_rate_data)) return asyncReturn(cached) if cached else deferToThread(get_rate_data)