Skip to content

Commit

Permalink
fix: Increase the number of threads when importing everything.
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.  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'
```
  • Loading branch information
feanil committed Oct 17, 2024
1 parent 2ff9732 commit 297f899
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions codejail/tests/test_safe_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down

0 comments on commit 297f899

Please sign in to comment.