From 28d97c62f2f3a4d559606ddbb34e5189c5ed6070 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 17 Oct 2024 10:59:11 -0400 Subject: [PATCH] fix: Don't run so many OpenBlas threads. Importing all of numpy loads OpenBlas which spawns many worker threads behind the scenes. Increasing the number of threads didn't seem to work. I got up to 30 before deciding that it would be better for the test to just limit the number of OpenBLAS threads. The addition of the following code seems to resolve the issue: ``` import os os.environ['OPENBLAS_NUM_THREADS'] = '1' ``` Reference: https://stackoverflow.com/questions/52026652/openblas-blas-thread-init-pthread-create-resource-temporarily-unavailable --- codejail/tests/test_safe_exec.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codejail/tests/test_safe_exec.py b/codejail/tests/test_safe_exec.py index c876213d..97e09af2 100644 --- a/codejail/tests/test_safe_exec.py +++ b/codejail/tests/test_safe_exec.py @@ -101,6 +101,8 @@ def test_importing_lots_of_crap(self): set_limit('REALTIME', 10) globs = {} self.safe_exec(textwrap.dedent("""\ + import os + os.environ['OPENBLAS_NUM_THREADS'] = '1' from numpy import * a = 1723 """), globs)