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 
31 
32 namespace {
33  std::once_flag pluginFlag;
34  int setupPluginSystem() {
35  std::call_once(pluginFlag, []() { edmplugin::PluginManager::configure(edmplugin::standard::config()); });
36  return 0;
37  }
38 
39  std::shared_ptr<edm::ProcessDesc> addDefaultServicesToProcessDesc(std::shared_ptr<edm::ProcessDesc> iDesc) {
40  iDesc->addServices(edm::defaultCmsRunServices());
41  return iDesc;
42  }
43 
44  edm::ServiceToken createJobReport() {
47  std::make_unique<edm::JobReport>(nullptr)));
48  }
49 } // namespace
50 
51 //
52 // constants, enums and typedefs
53 //
54 
55 //
56 // static data member definitions
57 //
58 
59 //
60 // constructors and destructor
61 //
63  : forcePluginSetupFirst_(setupPluginSystem()),
64  processor_(addDefaultServicesToProcessDesc(iDesc.processDesc()),
65  createJobReport(),
66  edm::serviceregistry::kOverlapIsError) {}
67 
69  auto gil = PyEval_SaveThread();
70  // Protects the destructor from throwing exceptions.
71  CMS_SA_ALLOW try { processor_.endJob(); } catch (...) {
72  }
73  PyEval_RestoreThread(gil);
74 }
75 
77  auto gil = PyEval_SaveThread();
78  try {
80  } catch (...) {
81  }
82  PyEval_RestoreThread(gil);
83 }
edm::defaultCmsRunServices
std::vector< std::string > defaultCmsRunServices()
Definition: defaultCmsRunServices.cc:19
ServiceRegistry.h
PythonEventProcessor::processor_
edm::EventProcessor processor_
Definition: PythonEventProcessor.h:60
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EventProcessor::endJob
void endJob()
Definition: EventProcessor.cc:579
edm::EventProcessor::runToCompletion
StatusCode runToCompletion()
Definition: EventProcessor.cc:677
ServiceToken.h
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::ServiceToken
Definition: ServiceToken.h:40
ProcessDesc.h
PyBind11ProcessDesc.h
PythonEventProcessor.h
PyBind11ProcessDesc
Definition: PyBind11ProcessDesc.h:16
standard.h
PythonEventProcessor::run
void run()
Definition: PythonEventProcessor.cc:76
PythonEventProcessor::PythonEventProcessor
PythonEventProcessor(PyBind11ProcessDesc const &)
Definition: PythonEventProcessor.cc:62
edmplugin::PluginManager::configure
static PluginManager & configure(const Config &)
Definition: PluginManager.cc:316
thread_safety_macros.h
edm::serviceregistry::kOverlapIsError
Definition: ServiceLegacy.h:29
edmplugin::standard::config
PluginManager::Config config()
Definition: standard.cc:21
PluginManager.h
edm::ServiceRegistry::createContaining
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
Definition: ServiceRegistry.h:97
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:29
PythonEventProcessor::~PythonEventProcessor
~PythonEventProcessor()
Definition: PythonEventProcessor.cc:68
defaultCmsRunServices.h
JobReport.h
edm::serviceregistry::ServiceWrapper
Definition: ServiceRegistry.h:35