Skip to content

Commit

Permalink
Merge pull request #1375 from locustio/try-to-set-open-file-limit-and…
Browse files Browse the repository at this point in the history
…-warn-if-it-is-too-low

Try to increase open files limit and warn if it is still too low afterwards
  • Loading branch information
cyberw authored May 22, 2020
2 parents 06266b2 + 49ce465 commit 35cb1d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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,14 @@ def main():
# list() call is needed to consume the dict_view object in Python 3
user_classes = list(user_classes.values())

try:
if resource.getrlimit(resource.RLIMIT_NOFILE)[0] < 10000:
# Increasing the limit to 10000 within a running process should work on at least MacOS.
# It does not work on all OS:es, but we should be no worse off for trying.
resource.setrlimit(resource.RLIMIT_NOFILE, [10000, resource.RLIM_INFINITY])
except:
logger.warning("System open file limit setting is not high enough for load testing, and the OS wouldnt allow locust to increase it by itself. 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 35cb1d9

Please sign in to comment.