The Gaudi Framework  v36r1 (3e2fb5a8)
SubSlotException.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
12 '''
13 A test for an incorrect handling of exceptions from algorithms running in sub-slots
14 
15 Throwing an exception causes the event to be marked as failed.
16 It also means that the part of the code that updates the algorithm state is bypassed.
17 Since the AlgExecStateSvc does not (currently) understand sub-slots,
18 if the exception is thrown by an alg in sub-slot 2, the state for that same alg
19 in sub-slot 1 is retrieved.
20 
21 So, it is possible to have a failed event, without any algorihms in ERROR state.
22 The scheduler does not have handling for this, and hangs.
23 
24 '''
25 from Gaudi.Configuration import *
26 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
27  AvalancheSchedulerSvc, AlgResourcePool, CPUCruncher,
28  GaudiSequencer, Test__ViewTester,
29  GaudiTesting__StopLoopAlg)
30 
31 # metaconfig -------------------------------------------------------------------
32 # It's confortable to collect the relevant parameters at the top of the optionfile
33 evtslots = 1
34 evtMax = 10
35 cardinality = 1
36 threads = 1
37 viewsPerEvt = 2
38 # -------------------------------------------------------------------------------
39 
40 # The configuration of the whiteboard ------------------------------------------
41 # It is useful to call it EventDataSvc to replace the usual data service with
42 # the whiteboard transparently.
43 
44 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
45 
46 # -------------------------------------------------------------------------------
47 
48 # Event Loop Manager -----------------------------------------------------------
49 # It's called slim since it has less functionalities overall than the good-old
50 # event loop manager. Here we just set its outputlevel to INFO.
51 
52 slimeventloopmgr = HiveSlimEventLoopMgr(
53  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO)
54 
55 # -------------------------------------------------------------------------------
56 
57 # ForwardScheduler -------------------------------------------------------------
58 # We just decide how many algorithms in flight we want to have and how many
59 # threads in the pool. The default value is -1, which is for TBB equivalent
60 # to take over the whole machine.
61 
62 scheduler = AvalancheSchedulerSvc(
63  ThreadPoolSize=threads, OutputLevel=INFO, VerboseSubSlots=True)
64 
65 # -------------------------------------------------------------------------------
66 
67 # Algo Resource Pool -----------------------------------------------------------
68 # Nothing special here, we just set the debug level.
69 AlgResourcePool(OutputLevel=INFO)
70 
71 # -------------------------------------------------------------------------------
72 
73 # Set up of the crunchers, daily business --------------------------------------
74 
75 a1 = Test__ViewTester("A1")
76 a1.baseViewName = 'view'
77 a1.viewNumber = viewsPerEvt
78 a1.viewNodeName = 'viewNode'
79 
80 a2 = Test__ViewTester("A2")
81 a2.viewNodeName = ''
82 
83 # EventCount is tracked by a private member of the algorithm, so increments whenever it is run
84 # EventCount = 2 corresponds to the 1st view of the 2nd event, giving a correctly-handled exception
85 # EventCount = 3 corresponds to the 2nd view of the 2nd event, causing the hang
86 a3 = GaudiTesting__StopLoopAlg("A3", EventCount=3, Mode="exception")
87 
88 a4 = Test__ViewTester("A4")
89 a4.viewNodeName = ''
90 
91 for algo in [a1, a2, a3, a4]:
92  algo.Cardinality = cardinality
93  algo.OutputLevel = INFO
94 
95 viewNode = GaudiSequencer(
96  "viewNode",
97  Members=[a2, a3],
98  Sequential=False,
99  ShortCircuit=False,
100  OutputLevel=INFO)
101 
102 createViewSeq = GaudiSequencer(
103  "createViewSeq",
104  Members=[a1, viewNode, a4],
105  Sequential=True,
106  OutputLevel=INFO)
107 
108 # Application Manager ----------------------------------------------------------
109 # We put everything together and change the type of message service
110 
112  EvtMax=evtMax,
113  EvtSel='NONE',
114  ExtSvc=[whiteboard],
115  EventLoop=slimeventloopmgr,
116  TopAlg=[createViewSeq],
117  MessageSvcType="InertMessageSvc")
118 
119 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57