Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfiola committed Jan 29, 2024
1 parent f56fe6f commit c3db14d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/grasshopper/lib/grasshopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import logging
import os
import signal
from typing import Dict, List, Optional, Type, Union

if os.name == "posix":
import resource # pylint: disable=import-error
from typing import Dict, List, Optional, Type, Union


import gevent
import locust
Expand Down Expand Up @@ -199,8 +201,8 @@ def load_shape(shape_name: str, **kwargs) -> LoadTestShape:
def set_ulimit():
"""Increase the maximum number of open files allowed."""
# Adapted from locust source code, main function in locust.main.
if os.name == "posix":
try:
try:
if os.name == "posix":
minimum_open_file_limit = 10000
current_open_file_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
if current_open_file_limit < minimum_open_file_limit:
Expand All @@ -211,11 +213,11 @@ def set_ulimit():
resource.RLIMIT_NOFILE,
[minimum_open_file_limit, resource.RLIM_INFINITY],
)
except BaseException:
logger.warning(
f"""System open file limit '{current_open_file_limit}' is below minimum
setting '{minimum_open_file_limit}'. It's not high enough for load
testing, and the OS didn't allow locust to increase it by itself. See
https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit
for more info."""
)
except BaseException:
logger.warning(
f"""System open file limit '{current_open_file_limit}' is below minimum
setting '{minimum_open_file_limit}'. It's not high enough for load
testing, and the OS didn't allow locust to increase it by itself. See
https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit
for more info."""
)

0 comments on commit c3db14d

Please sign in to comment.