File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+
2+
3+ from asyncio import AbstractEventLoop
4+ from asyncio import Future
5+ import asyncio
6+
7+ class EventLoop (AbstractEventLoop ):
8+ __running = False
9+
10+ def __init__ (self ):
11+ super ().__init__ ()
12+
13+ def run_until_complete (self , future : Future ):
14+ pass
15+
16+ def start (self ):
17+ self .__running = True
18+
19+ def is_running (self ):
20+ return self .__running
21+
22+ async def workflow ():
23+ asyncio .set_event_loop (EventLoop ())
24+
25+ task1 = asyncio .create_task (delay_print ("Hello, world!" , 1 ))
26+ task2 = asyncio .create_task (delay_print ("Hello, world!" , 1 ))
27+ await task1
28+ await task2
29+
30+
31+ async def delay_print (message , delay ):
32+ await asyncio .sleep (delay )
33+ print (message )
34+
35+
36+ if __name__ == "__main__" :
37+ print ("Starting workflow" )
38+ loop = asyncio .new_event_loop ()
39+ loop .start ()
40+ loop .run_until_complete (workflow ())
You can’t perform that action at this time.
0 commit comments