diff --git a/locust/main.py b/locust/main.py index e5bcfb95ed..186ea21901 100644 --- a/locust/main.py +++ b/locust/main.py @@ -6,6 +6,7 @@ import socket import sys import time +import resource import gevent @@ -153,6 +154,15 @@ def main(): # list() call is needed to consume the dict_view object in Python 3 user_classes = list(user_classes.values()) + try: + # 24576 is the highest value I was able to set this on MacOS Mojave without getting an error + resource.setrlimit(resource.RLIMIT_NOFILE, [24576, resource.RLIM_INFINITY]) + except: + pass # this will fail on linux, not sure about windows + + if resource.getrlimit(resource.RLIMIT_NOFILE)[0] < 10000: + logger.warning("System open file limit setting is not high enough for load testing. See https://docs.locust.io/en/stable/installation.html#increasing-maximum-number-of-open-files-limit for more info.") + # create locust Environment environment = create_environment(user_classes, options, events=locust.events)