Skip to content

Commit

Permalink
fix: set memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Oct 24, 2024
1 parent 5d76b34 commit a2973c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mutmut/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
dedent,
indent,
)
import resource

from threading import Thread
from typing import (
Dict,
Expand Down Expand Up @@ -129,6 +131,10 @@ def guess_paths_to_mutate():
'Could not figure out where the code to mutate is. '
'Please specify it on the command line using --paths-to-mutate, '
'or by adding "paths_to_mutate=code_dir" in setup.cfg to the [mutmut] section.')

def limit_memory(maxsize):
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (maxsize, hard))


def record_trampoline_hit(name):
Expand Down Expand Up @@ -1226,6 +1232,7 @@ def read_one_child_exit_status():
# In the child
os.environ['MUTANT_UNDER_TEST'] = mutant_name
setproctitle(f'mutmut: {mutant_name}')
limit_memory(1000*1000*500)

# Run fast tests first
tests = sorted(tests, key=lambda test_name: mutmut.duration_by_test[test_name])
Expand Down

0 comments on commit a2973c8

Please sign in to comment.