We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ded654 commit 6bff4dbCopy full SHA for 6bff4db
asyncio_slow/test_chain.py
@@ -0,0 +1,18 @@
1
+#https://docs.python.org/3.4/library/asyncio-task.html#example-chain-coroutines
2
+#import asyncio
3
+import asyncio_slow as asyncio
4
+
5
+@asyncio.coroutine
6
+def compute(x, y):
7
+ print("Compute %s + %s ..." % (x, y))
8
+ yield from asyncio.sleep(1.0)
9
+ return x + y
10
11
12
+def print_sum(x, y):
13
+ result = yield from compute(x, y)
14
+ print("%s + %s = %s" % (x, y, result))
15
16
+loop = asyncio.get_event_loop()
17
+loop.run_until_complete(print_sum(1, 2))
18
+loop.close()
0 commit comments