From 3fd21bbef981cb6720965b575eac80f8f808ba88 Mon Sep 17 00:00:00 2001
From: Stewart Martin-Haugh <smh@cern.ch>
Date: Fri, 14 Jun 2019 13:53:10 +0200
Subject: [PATCH] Move evtMax and skipEvents options to Execution, so they work
 in interactive jobs

---
 Control/AthenaCommon/share/Execution.py | 11 +++++++++++
 Control/AthenaCommon/share/runbatch.py  |  8 --------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/Control/AthenaCommon/share/Execution.py b/Control/AthenaCommon/share/Execution.py
index ad53016995d..03751374fd8 100644
--- a/Control/AthenaCommon/share/Execution.py
+++ b/Control/AthenaCommon/share/Execution.py
@@ -85,6 +85,17 @@ else:
       import AthenaMP.PyComps as _amppy
       svcMgr += _amppy.MpEvtLoopMgr(NWorkers=opts.nprocs)
 
+   #if EvtMax and SkipEvents are set, use them
+   from AthenaCommon.AthenaCommonFlags import jobproperties as jps
+   if jps.AthenaCommonFlags.EvtMax.statusOn:
+      theApp.EvtMax = jps.AthenaCommonFlags.EvtMax()
+   if jps.AthenaCommonFlags.SkipEvents.statusOn:
+      if hasattr(svcMgr,"EventSelector"):
+         svcMgr.EventSelector.SkipEvents = jps.AthenaCommonFlags.SkipEvents()
+      else:
+         _msg.warning('No EventSelector in svcMgr, not skipping events')
+
+
  ## in batch, run as many events as requested, otherwise explain
    if opts.run_batch:
       ## enable or not athena-mp
diff --git a/Control/AthenaCommon/share/runbatch.py b/Control/AthenaCommon/share/runbatch.py
index c5e9fb01358..3ca06f7e0c2 100755
--- a/Control/AthenaCommon/share/runbatch.py
+++ b/Control/AthenaCommon/share/runbatch.py
@@ -8,14 +8,6 @@
 #   athena.py <myJobOptions.py> runbatch.py
 
 try:
-   #if EvtMax and SkipEvents are set, use them
-   from AthenaCommon.AthenaCommonFlags import jobproperties as jps
-   if jps.AthenaCommonFlags.EvtMax.statusOn:
-      theApp.EvtMax = jps.AthenaCommonFlags.EvtMax()
-   if jps.AthenaCommonFlags.SkipEvents.statusOn:
-      if hasattr(svcMgr,"EventSelector"):
-         svcMgr.EventSelector.SkipEvents = jps.AthenaCommonFlags.SkipEvents()
-
    theApp.run()     # runs until theApp.EvtMax events reached
    from AthenaCommon.Debugging import hookDebugger,DbgStage
    if DbgStage.value == "fini":
-- 
GitLab