-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest1-FramePenetration.py
44 lines (33 loc) · 1.05 KB
/
test1-FramePenetration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from SimilarNeuron import FramePenetration, AsyncFramePenetration
import asyncio
class Event_A():
def __repr__(self):
return 'Event_A'
class Event_B():
def __repr__(self):
return 'Event_B'
class Event_C():
def __repr__(self):
return 'Event_C'
def main_1(a: Event_A, b: Event_B, c: Event_C):
print(a, b, c)
return a,b,c
def main_2(b: Event_B, c: Event_C):
print(b, c)
return b,c
async def main_3(a: Event_A, b: Event_B, c: Event_C):
print(a, b, c)
return a,b,c
async def main_4(b: Event_B, c: Event_C):
print(b, c)
return b,c
e3: Event_C = Event_C()
def receiver(e1: Event_A, e2: Event_B):
with FramePenetration(introduce={'e3': e3}) as runfunc:
print(runfunc(main_1, main_2))
async def receiver_async(e1: Event_A, e2: Event_B):
async with AsyncFramePenetration(e3) as runfunc:
print(await runfunc(main_3, main_4, concurrent = True))
receiver(Event_A(), Event_B())
asyncio.run(receiver_async(Event_A(), Event_B()))
# await receiver_async(Event_A(), Event_B()) # In jupyter