-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (40 loc) · 1.27 KB
/
main.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
47
48
49
50
51
52
53
54
import subprocess
import os
from subprocess import Popen,PIPE
number_of_producers = int(input("Enter number of producers: "))
number_of_consumers = int(input("Enter number of consumers: "))
number_of_brokers = 3
commands = []
commands.append("python broker1_flask.py")
commands.append("python broker1_TCP.py")
commands.append("python broker2.py")
commands.append("python broker3.py")
for i in range(number_of_consumers):
commands.append("python consumer.py")
for i in range(number_of_producers):
commands.append("python producer.py")
#commands.append("python mini_zookeeper.py")
print(len(commands))
procs = [ Popen(i) for i in commands ]
for p in procs:
p.wait()
'''
def create_brokers():
for i in range(number_of_brokers):
program_broker = "broker.py"
Popen(program_broker)
print("created broker: {}").format(i)
def create_consumers():
for i in range(number_of_consumers):
program_consumer = "producer.py"
Popen(program_consumer)
print("created consumer: {}").format(i)
def create_producers():
for i in range(number_of_producers):
program_producer = "consumer.py"
Popen(program_producer)
print("created producer: {}").format(i)
create_brokers()
create_consumers()
create_producers()
'''