File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ try :
2
+ import uasyncio .core as asyncio
3
+ except ImportError :
4
+ import asyncio
5
+ import logging
6
+ #logging.basicConfig(level=logging.DEBUG)
7
+ #asyncio.set_debug(True)
8
+
9
+
10
+ def looper (iters ):
11
+ for i in range (iters ):
12
+ print ("ping" )
13
+ yield from asyncio .sleep (1.0 )
14
+ return 10
15
+
16
+
17
+ def run_to ():
18
+ try :
19
+ ret = yield from asyncio .wait_for (looper (2 ), 1 )
20
+ print ("result:" , ret )
21
+ assert False
22
+ except asyncio .TimeoutError :
23
+ print ("Coro timed out" )
24
+
25
+ print ("=================" )
26
+
27
+ try :
28
+ ret = yield from asyncio .wait_for (looper (2 ), 2 )
29
+ print ("result:" , ret )
30
+ assert False
31
+ except asyncio .TimeoutError :
32
+ print ("Coro timed out" )
33
+
34
+ print ("=================" )
35
+
36
+ try :
37
+ ret = yield from asyncio .wait_for (looper (2 ), 3 )
38
+ print ("result:" , ret )
39
+ except asyncio .TimeoutError :
40
+ print ("Coro timed out" )
41
+ assert False
42
+
43
+
44
+ loop = asyncio .get_event_loop ()
45
+ loop .run_until_complete (run_to ())
46
+ loop .run_until_complete (asyncio .sleep (1 ))
You can’t perform that action at this time.
0 commit comments