from twisted.internet.defer import inlineCallbacks
from twisted.internet.defer import Deferred
from twisted.internet import defer
@inlineCallbacks
def got():
x = yield 'k22'
defer.returnValue(x)
@inlineCallbacks
def run():
print("in run")
result = yield got()
print("after yield")
# print(next(result))
print("in run's result: {0}".format(result))
defer.returnValue("return 42")
if __name__ == "__main__":
print("Start in main")
result = run()
print("End after run")
print("Result: {0}".format(result))
print(result.result)
Jul 22, 2016
[python][twisted] how defer works
twisted inlineCallbacks
Labels:
python,
python_twisted
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.