Skip to content

Commit

Permalink
Try to increase open files limit and warn if it is still too low afte…
Browse files Browse the repository at this point in the history
…rwards. adresses #1368
  • Loading branch information
cyberw committed May 15, 2020
1 parent e10f4bd commit 81c0222
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import socket
import sys
import time
import resource

import gevent

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 81c0222

Please sign in to comment.