diff --git a/docs/release.rst b/docs/release.rst index e3e4ed62..7a0ba17f 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -18,8 +18,12 @@ Release notes * Updated the msgpack dependency (by :user:`Jerome Kelleher `; :issue:`74`, :issue:`75`). +* Allow :class:`Blosc` compressor to run on systems where locks are not present (by + :user:`Marcus Kinsella `; :issue:`#83`). + * Drop Python 3.4 (by :user:`John Kirkham `; :issue:`89`). + .. _release_0.5.5: 0.5.5 diff --git a/numcodecs/blosc.pyx b/numcodecs/blosc.pyx index 85c52909..11766079 100644 --- a/numcodecs/blosc.pyx +++ b/numcodecs/blosc.pyx @@ -76,8 +76,10 @@ AUTOSHUFFLE = -1 AUTOBLOCKS = 0 # synchronization -mutex = multiprocessing.Lock() - +try: + mutex = multiprocessing.Lock() +except OSError: + mutex = None # store ID of process that first loads the module, so we can detect a fork later _importer_pid = os.getpid() @@ -405,6 +407,10 @@ def _get_use_threads(): global use_threads proc = multiprocessing.current_process() + # check if locks are available, and if not no threads + if not mutex: + return False + # check for fork if proc.pid != _importer_pid: # If this module has been imported in the parent process, and the current process