mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix: check if gevent installed when running locusts
This commit is contained in:
+12
-2
@@ -4,8 +4,18 @@ import sys
|
|||||||
|
|
||||||
if len(sys.argv) >= 2 and sys.argv[1] == "locusts":
|
if len(sys.argv) >= 2 and sys.argv[1] == "locusts":
|
||||||
# monkey patch ssl at beginning to avoid RecursionError when running locust.
|
# monkey patch ssl at beginning to avoid RecursionError when running locust.
|
||||||
from gevent import monkey
|
try:
|
||||||
monkey.patch_ssl()
|
from gevent import monkey
|
||||||
|
monkey.patch_ssl()
|
||||||
|
from locust.main import main
|
||||||
|
except ImportError:
|
||||||
|
msg = """
|
||||||
|
Locust is not installed, install first and try again.
|
||||||
|
install with pip:
|
||||||
|
$ pip install locustio
|
||||||
|
"""
|
||||||
|
print(msg)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|||||||
@@ -29,17 +29,6 @@ def init_parser_locusts(subparsers):
|
|||||||
def main_locusts(args, extra_args):
|
def main_locusts(args, extra_args):
|
||||||
""" Performance test with locust: parse command line options and run commands.
|
""" Performance test with locust: parse command line options and run commands.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
from locust.main import main
|
|
||||||
except ImportError:
|
|
||||||
msg = """
|
|
||||||
Locust is not installed, install first and try again.
|
|
||||||
install with pip:
|
|
||||||
$ pip install locustio
|
|
||||||
"""
|
|
||||||
logger.error(msg)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
logger.info(f"HttpRunner version: {__version__}")
|
logger.info(f"HttpRunner version: {__version__}")
|
||||||
sys.argv = ["locust", *extra_args]
|
sys.argv = ["locust", *extra_args]
|
||||||
|
|
||||||
@@ -86,5 +75,8 @@ def main_locusts(args, extra_args):
|
|||||||
start_master(sys.argv)
|
start_master(sys.argv)
|
||||||
elif args.slaves:
|
elif args.slaves:
|
||||||
start_slaves(args.slaves)
|
start_slaves(args.slaves)
|
||||||
|
else:
|
||||||
|
quick_run_locusts(CPU_COUNT)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
manager.shutdown()
|
manager.shutdown()
|
||||||
|
|||||||
Reference in New Issue
Block a user