Skip to content

Commit c54bc3d

Browse files
committed
Fail gracefully if multiprocessing is not available
1 parent c0697e5 commit c54bc3d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎numcodecs/__init__.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@
4343
from numcodecs import blosc
4444
from numcodecs.blosc import Blosc
4545
register_codec(Blosc)
46-
# initialize blosc
47-
ncores = multiprocessing.cpu_count()
46+
# initialize blosc, failing gracefully if no multiprocessing
47+
try:
48+
ncores = multiprocessing.cpu_count()
49+
except OSError:
50+
ncores = 1
4851
blosc.init()
4952
blosc.set_nthreads(min(8, ncores))
5053
atexit.register(blosc.destroy)

0 commit comments

Comments
 (0)