[英]Wrap value in twisted deferred
There is function which must return a deferred object, but I get a value synchronously. 有必须返回一个延迟对象的函数,但是我同步获得一个值。
Now I am returning that value with inlineCallbacks
decorator: 现在,我使用inlineCallbacks
装饰器返回该值:
@defer.inlineCallbacks
def collect(self, config):
yield
data = new_data() # synchronous call
defer.returnValue(data)
But may be there is some function which wraps value in deferred object, which than is immediately called? 但是可能存在一些将值包装在延迟对象中的函数,该函数立即被调用吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.