mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
bugfix: start locust slave on other machines
This commit is contained in:
+10
-3
@@ -54,12 +54,16 @@ def start_master(sys_argv):
|
|||||||
main()
|
main()
|
||||||
|
|
||||||
def start_slave(sys_argv):
|
def start_slave(sys_argv):
|
||||||
sys_argv.extend(["--slave"])
|
if "--slave" not in sys_argv:
|
||||||
|
sys_argv.extend(["--slave"])
|
||||||
|
|
||||||
sys.argv = sys_argv
|
sys.argv = sys_argv
|
||||||
main()
|
main()
|
||||||
|
|
||||||
def run_locusts_on_cpu_cores(sys_argv, cpu_cores_num_value):
|
def run_locusts_on_cpu_cores(sys_argv, cpu_cores_num_value):
|
||||||
processes = []
|
processes = []
|
||||||
|
manager = multiprocessing.Manager()
|
||||||
|
|
||||||
for _ in range(cpu_cores_num_value):
|
for _ in range(cpu_cores_num_value):
|
||||||
p_slave = multiprocessing.Process(target=start_slave, args=(sys_argv,))
|
p_slave = multiprocessing.Process(target=start_slave, args=(sys_argv,))
|
||||||
p_slave.daemon = True
|
p_slave.daemon = True
|
||||||
@@ -67,6 +71,9 @@ def run_locusts_on_cpu_cores(sys_argv, cpu_cores_num_value):
|
|||||||
processes.append(p_slave)
|
processes.append(p_slave)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
start_master(sys_argv)
|
if "--slave" in sys_argv:
|
||||||
|
[process.join() for process in processes]
|
||||||
|
else:
|
||||||
|
start_master(sys_argv)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(0)
|
manager.shutdown()
|
||||||
|
|||||||
Reference in New Issue
Block a user