File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 66# System Imports
77import logging
88import os
9+ import platform
910import re
1011import sys
1112import time
@@ -36,6 +37,19 @@ class UnexpectedError(Exception):
3637 pass
3738
3839
40+ if platform .system () == "Linux" or platform .system () == "Darwin" :
41+ import resource
42+
43+ # Get total system memory
44+ total_memory = os .sysconf ("SC_PAGE_SIZE" ) * os .sysconf (
45+ "SC_PHYS_PAGES"
46+ ) # Set memory limit to 80% of total system memory
47+ memory_limit = int (total_memory * 0.8 )
48+
49+ # Set both soft and hard limits
50+ resource .setrlimit (resource .RLIMIT_AS , (memory_limit , memory_limit ))
51+
52+
3953def pytest_addoption (parser : Parser ) -> None :
4054 """Add command line options."""
4155 pytest_loops = parser .getgroup ("loops" )
You can’t perform that action at this time.
0 commit comments