Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 Configurables import (
26  AlgResourcePool,
27  AvalancheSchedulerSvc,
28  CPUCruncher,
29  GaudiSequencer,
30  GaudiTesting__StopLoopAlg,
31  HiveSlimEventLoopMgr,
32  HiveWhiteBoard,
33  Test__ViewTester,
34 )
35 from Gaudi.Configuration import *
36 
37 # metaconfig -------------------------------------------------------------------
38 # It's confortable to collect the relevant parameters at the top of the optionfile
39 evtslots = 1
40 evtMax = 10
41 cardinality = 1
42 threads = 1
43 viewsPerEvt = 2
44 # -------------------------------------------------------------------------------
45 
46 # The configuration of the whiteboard ------------------------------------------
47 # It is useful to call it EventDataSvc to replace the usual data service with
48 # the whiteboard transparently.
49 
50 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
51 
52 # -------------------------------------------------------------------------------
53 
54 # Event Loop Manager -----------------------------------------------------------
55 # It's called slim since it has less functionalities overall than the good-old
56 # event loop manager. Here we just set its outputlevel to INFO.
57 
58 slimeventloopmgr = HiveSlimEventLoopMgr(
59  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO
60 )
61 
62 # -------------------------------------------------------------------------------
63 
64 # ForwardScheduler -------------------------------------------------------------
65 # We just decide how many algorithms in flight we want to have and how many
66 # threads in the pool. The default value is -1, which is for TBB equivalent
67 # to take over the whole machine.
68 
69 scheduler = AvalancheSchedulerSvc(
70  ThreadPoolSize=threads, OutputLevel=INFO, VerboseSubSlots=True
71 )
72 
73 # -------------------------------------------------------------------------------
74 
75 # Algo Resource Pool -----------------------------------------------------------
76 # Nothing special here, we just set the debug level.
77 AlgResourcePool(OutputLevel=INFO)
78 
79 # -------------------------------------------------------------------------------
80 
81 # Set up of the crunchers, daily business --------------------------------------
82 
83 a1 = Test__ViewTester("A1")
84 a1.baseViewName = "view"
85 a1.viewNumber = viewsPerEvt
86 a1.viewNodeName = "viewNode"
87 
88 a2 = Test__ViewTester("A2")
89 a2.viewNodeName = ""
90 
91 # EventCount is tracked by a private member of the algorithm, so increments whenever it is run
92 # EventCount = 2 corresponds to the 1st view of the 2nd event, giving a correctly-handled exception
93 # EventCount = 3 corresponds to the 2nd view of the 2nd event, causing the hang
94 a3 = GaudiTesting__StopLoopAlg("A3", EventCount=3, Mode="exception")
95 
96 a4 = Test__ViewTester("A4")
97 a4.viewNodeName = ""
98 
99 for algo in [a1, a2, a3, a4]:
100  algo.Cardinality = cardinality
101  algo.OutputLevel = INFO
102 
103 viewNode = GaudiSequencer(
104  "viewNode", Members=[a2, a3], Sequential=False, ShortCircuit=False, OutputLevel=INFO
105 )
106 
107 createViewSeq = GaudiSequencer(
108  "createViewSeq", Members=[a1, viewNode, a4], Sequential=True, OutputLevel=INFO
109 )
110 
111 # Application Manager ----------------------------------------------------------
112 # We put everything together and change the type of message service
113 
115  EvtMax=evtMax,
116  EvtSel="NONE",
117  ExtSvc=[whiteboard],
118  EventLoop=slimeventloopmgr,
119  TopAlg=[createViewSeq],
120  MessageSvcType="InertMessageSvc",
121 )
122 
123 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57