-
Notifications
You must be signed in to change notification settings - Fork 2
/
mprocess.py
46 lines (40 loc) · 1.17 KB
/
mprocess.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
45
46
import asyncio
import functools
import concurrent.futures
from engine import Engine
from multiprocessing import Manager, Queue
if __name__ == "__main__":
loop = asyncio.get_event_loop()
manager=Manager()
queue_suma=manager.Queue()
queue_resta=manager.Queue()
a=2
b=3
w=.05
engine=Engine(a=a,b=b,w=w, mode='mprocess')
with concurrent.futures.ProcessPoolExecutor() as executor:
def suma_process():
print(engine)
engine.suma_task(queue_suma)
def resta_process():
print(engine)
engine.resta_task(queue_resta)
def seno_process():
print(engine)
engine.seno_task(queue_suma,queue_resta)
loop.run_in_executor(
executor,
#functools.partial(engine.suma_task,queue_suma)
suma_process
)
loop.run_in_executor(
executor,
resta_process
)
loop.run_in_executor(
executor,
seno_process
)
#await engine.resta_task(queue_resta)
#await engine.seno_task(queue_suma, queue_resta)
loop.run_forever()