From 297f899b7faf42ad7a590b8d30383283452f90da Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 17 Oct 2024 10:59:11 -0400 Subject: [PATCH] fix: Increase the number of threads when importing everything. Importing all of numpy loads OpenBlas which spawns many worker threads behind the scenes. We need to increase the number of threads that are allowed when importing "lots of crap". The other option would be to limit the number of threads that OpenBLAS uses by setting the `OPENBLASH_NUM_THREADS` environment variable: ``` import os os.environ['OPENBLAS_NUM_THREADS'] = '1' ``` --- codejail/tests/test_safe_exec.py | 1 + 1 file changed, 1 insertion(+) diff --git a/codejail/tests/test_safe_exec.py b/codejail/tests/test_safe_exec.py index c876213d..d30d963e 100644 --- a/codejail/tests/test_safe_exec.py +++ b/codejail/tests/test_safe_exec.py @@ -99,6 +99,7 @@ def test_printing_stuff_when_you_shouldnt(self): def test_importing_lots_of_crap(self): set_limit('REALTIME', 10) + set_limit('NPROC', 30) globs = {} self.safe_exec(textwrap.dedent("""\ from numpy import *