CMS 3D CMS Logo

PythonEventProcessor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Subsystem/Package
4 // Class : PythonEventProcessor
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: root
10 // Created: Fri, 20 Jan 2017 16:36:41 GMT
11 //
12 
13 // system include files
14 #include <mutex>
15 
16 // user include files
19 
22 
25 
27 
30 
31 namespace {
32  std::once_flag pluginFlag;
33  int setupPluginSystem() {
34  std::call_once(pluginFlag, []() {
36  });
37  return 0;
38  }
39 
40  std::shared_ptr<edm::ProcessDesc> addDefaultServicesToProcessDesc(std::shared_ptr<edm::ProcessDesc> iDesc) {
41  iDesc->addServices(edm::defaultCmsRunServices());
42  return iDesc;
43  }
44 
45  edm::ServiceToken createJobReport() {
46  return edm::ServiceRegistry::createContaining(std::make_shared<edm::serviceregistry::ServiceWrapper<edm::JobReport>>(std::make_unique<edm::JobReport>(nullptr)));
47  }
48 }
49 
50 //
51 // constants, enums and typedefs
52 //
53 
54 //
55 // static data member definitions
56 //
57 
58 //
59 // constructors and destructor
60 //
62 : forcePluginSetupFirst_(setupPluginSystem())
63  ,processor_(addDefaultServicesToProcessDesc(iDesc.processDesc()),createJobReport(),edm::serviceregistry::kOverlapIsError)
64 {
65 }
66 
68 {
69  auto gil = PyEval_SaveThread();
70  try {
72  }catch(...) {
73 
74  }
75  PyEval_RestoreThread(gil);
76 }
77 
78 void
80 {
81  auto gil = PyEval_SaveThread();
82  try {
83  (void) processor_.runToCompletion();
84  }catch(...) {
85 
86  }
87  PyEval_RestoreThread(gil);
88 }
std::vector< std::string > defaultCmsRunServices()
static PluginManager & configure(const Config &)
edm::EventProcessor processor_
PluginManager::Config config()
Definition: standard.cc:21
PythonEventProcessor(PythonProcessDesc const &)
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
virtual StatusCode runToCompletion() override
HLT enums.