From ccffd3dacc3d9a672fc1a835c1afe262a3afa847 Mon Sep 17 00:00:00 2001
From: Marko Petric <marko.petric@cern.ch>
Date: Wed, 19 Feb 2020 15:34:44 +0100
Subject: [PATCH] check if already imported before importing libglapi

---
 DDDigi/python/DDDigi.py | 9 +++++----
 DDG4/python/DDG4.py     | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/DDDigi/python/DDDigi.py b/DDDigi/python/DDDigi.py
index 544fda473..d78afcff9 100644
--- a/DDDigi/python/DDDigi.py
+++ b/DDDigi/python/DDDigi.py
@@ -21,10 +21,11 @@ def loadDDDigi():
 
   # Try to load libglapi to avoid issues with TLS Static
   # Turn off all errors from ROOT about the library missing
-  orgLevel = ROOT.gErrorIgnoreLevel
-  ROOT.gErrorIgnoreLevel = 6000
-  gSystem.Load("libglapi")
-  ROOT.gErrorIgnoreLevel = orgLevel
+  if('libglapi' not in gSystem.GetLibraries()):
+    orgLevel = ROOT.gErrorIgnoreLevel
+    ROOT.gErrorIgnoreLevel = 6000
+    gSystem.Load("libglapi")
+    ROOT.gErrorIgnoreLevel = orgLevel
 
   import platform
   import os
diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py
index 4482c6a93..d3ae4d59a 100644
--- a/DDG4/python/DDG4.py
+++ b/DDG4/python/DDG4.py
@@ -22,10 +22,11 @@ def loadDDG4():
 
   # Try to load libglapi to avoid issues with TLS Static
   # Turn off all errors from ROOT about the library missing
-  orgLevel = ROOT.gErrorIgnoreLevel
-  ROOT.gErrorIgnoreLevel = 6000
-  gSystem.Load("libglapi")
-  ROOT.gErrorIgnoreLevel = orgLevel
+  if('libglapi' not in gSystem.GetLibraries()):
+    orgLevel = ROOT.gErrorIgnoreLevel
+    ROOT.gErrorIgnoreLevel = 6000
+    gSystem.Load("libglapi")
+    ROOT.gErrorIgnoreLevel = orgLevel
 
   import platform
   import os
-- 
GitLab