From dba93a2a4f5cee4708db8f045d4bc3b3ad2b6dde Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Thu, 25 Apr 2019 13:06:40 -0500 Subject: [PATCH 1/2] Make XRootDSource fork-safe By setting the appropriate environment variable --- uproot/source/xrootd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uproot/source/xrootd.py b/uproot/source/xrootd.py index 8777ee84..655ce98a 100644 --- a/uproot/source/xrootd.py +++ b/uproot/source/xrootd.py @@ -21,6 +21,9 @@ def __init__(self, path, timeout=None, *args, **kwds): def _open(self): try: + import os + # To make uproot + xrootd + multiprocessing work + os.environ['XRD_RUNFORKHANDLER'] = '1' import pyxrootd.client except ImportError: raise ImportError("Install pyxrootd package with:\n conda install -c conda-forge xrootd\n(or download from http://xrootd.org/dload.html and manually compile with cmake; setting PYTHONPATH and LD_LIBRARY_PATH appropriately).") From ca547704b27c766f36629b8a6b979ed6a38607a1 Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Thu, 25 Apr 2019 13:27:02 -0500 Subject: [PATCH 2/2] mostly just moved the import statement to the top of the file (it's a standard library one) --- uproot/source/xrootd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/uproot/source/xrootd.py b/uproot/source/xrootd.py index 655ce98a..cf32c04a 100644 --- a/uproot/source/xrootd.py +++ b/uproot/source/xrootd.py @@ -2,6 +2,7 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE +import os import threading import numpy @@ -21,9 +22,7 @@ def __init__(self, path, timeout=None, *args, **kwds): def _open(self): try: - import os - # To make uproot + xrootd + multiprocessing work - os.environ['XRD_RUNFORKHANDLER'] = '1' + os.environ["XRD_RUNFORKHANDLER"] = "1" # To make uproot + xrootd + multiprocessing work import pyxrootd.client except ImportError: raise ImportError("Install pyxrootd package with:\n conda install -c conda-forge xrootd\n(or download from http://xrootd.org/dload.html and manually compile with cmake; setting PYTHONPATH and LD_LIBRARY_PATH appropriately).")