Skip to content

Commit

Permalink
Related to #386. Wizard should bump ulimit
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Moy committed May 4, 2023
1 parent 91200ab commit a3b943d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion iambic/config/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def __init__(self, repo_dir: str):
self._default_region = None

asyncio.run(self.set_config_details())

check_and_update_resource_limit(self.config)
log.debug("Starting configuration wizard", config_path=self.config_path)

@property
Expand Down
22 changes: 9 additions & 13 deletions test/config/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import os
import pathlib
import resource
from tempfile import TemporaryDirectory
from unittest.mock import patch

import pytest

Expand Down Expand Up @@ -85,19 +85,15 @@ def config(repo_path):
return test_config


@patch("resource.setrlimit")
@patch("resource.getrlimit")
@patch("resource.RLIMIT_NOFILE")
def test_check_and_update_resource_limit(
mock_rlimit, mock_getrlimit, mock_setrlimit, config
):
mock_rlimit.value = 7
mock_getrlimit.return_value = (1024, 4096)
mock_setrlimit.return_value = None
def test_check_and_update_resource_limit(config):
cur_soft_limit, cur_hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
assert cur_soft_limit != 0
config.core.minimum_ulimit = cur_soft_limit * 2
check_and_update_resource_limit(config)
mock_setrlimit.assert_called_once_with(
mock_rlimit, (config.core.minimum_ulimit, 4096)
)
new_soft_limit, new_hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
assert new_soft_limit == config.core.minimum_ulimit
# restore original value
resource.setrlimit(resource.RLIMIT_NOFILE, (cur_soft_limit, cur_hard_limit))


@pytest.mark.asyncio
Expand Down

0 comments on commit a3b943d

Please sign in to comment.