This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
from twisted.internet import reactor | |
from twisted.internet.defer import inlineCallbacks, returnValue | |
from autobahn.twisted import util | |
def foo1(): | |
print("foo1") | |
return 1 | |
@inlineCallbacks | |
def foo2(): | |
print("foo2") | |
yield util.sleep(1) | |
returnValue(2) | |
def foo3(): | |
print("foo3") | |
yield util.sleep(1) | |
returnValue(3) | |
@inlineCallbacks | |
def test(): | |
print("foo1 is a coroutine: {}".format(inspect.isgeneratorfunction(foo1))) | |
print("foo2 is a coroutine: {}".format(inspect.isgeneratorfunction(foo2))) | |
print("foo3 is a coroutine: {}".format(inspect.isgeneratorfunction(foo3))) | |
foo1() | |
yield foo2() | |
foo3() | |
yield foo3() | |
reactor.stop() | |
test() | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment