Skip to content

Commit

Permalink
fix: Don't run so many OpenBlas threads.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
feanil committed Oct 17, 2024
1 parent 2ff9732 commit 28d97c6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions codejail/tests/test_safe_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 28d97c6

Please sign in to comment.