Coverage for src / competitive_verifier / resource.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-03-05 16:00 +0000

1import sys 

2from logging import getLogger 

3 

4logger = getLogger(__name__) 

5 

6 

7def ulimit_stack() -> None: 

8 """Run `ulimit -s unlimited`.""" 

9 if sys.platform not in ["win32", "darwin"]: # pragma: no cover 

10 import resource # noqa: PLC0415 

11 

12 _, hard = resource.getrlimit(resource.RLIMIT_STACK) 

13 resource.setrlimit(resource.RLIMIT_STACK, (hard, hard)) 

14 

15 

16def try_ulimit_stack() -> None: # pragma: no cover 

17 """Run `ulimit -s unlimited` and ignore any errors.""" 

18 try: 

19 ulimit_stack() 

20 except Exception: # noqa: BLE001 

21 logger.warning("failed to increase the stack size[ulimit]")