Skip to content

Commit cedc990

Browse files
committed
bug fix
1 parent 1e52b63 commit cedc990

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ostap/utils/root_utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,17 @@ def __init__ ( self , batch = True ) :
101101
## context manager: ENTER
102102
def __enter__ ( self ) :
103103
groot = ROOT.ROOT.GetROOT()
104-
self.__old_state = groot.IsBatch()
105-
if self.__old_state != self.__batch :
106-
groot.SetBatch ( self.__batch )
104+
if groot :
105+
self.__old_state = groot.IsBatch()
106+
if self.__old_state != self.__batch :
107+
groot.SetBatch ( self.__batch )
107108
return self
108109
## context manager: EXIT
109110
def __exit__ ( self , *_ ) :
110111
groot = ROOT.ROOT.GetROOT()
111-
if self.__old_state != groot.IsBatch() : root.SetBatch( self.__old_state )
112-
112+
if groot and self.__old_state != groot.IsBatch() :
113+
groot.SetBatch( self.__old_state )
114+
113115
# =============================================================================
114116
## check batch from environment variables, set it ans issue the message
115117
def batch_env ( logger = logger ) :

0 commit comments

Comments
 (0)