MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / onTrigger

Method onTrigger

extensions/script/python/ExecutePythonProcessor.cpp:125–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void ExecutePythonProcessor::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
126 if (!valid_init_) {
127 throw std::runtime_error("Could not correctly initialize " + getName());
128 }
129 try {
130 // TODO(hunyadi): When using "Script File" property, we currently re-read the script file content every time the processor is triggered. This should change to single-read when we release 1.0.0
131 // https://issues.apache.org/jira/browse/MINIFICPP-1223
132 reloadScriptIfUsingScriptFileProperty();
133 if (script_to_exec_.empty()) {
134 throw std::runtime_error("Neither Script Body nor Script File is available to execute");
135 }
136
137 std::shared_ptr<python::PythonScriptEngine> engine = getScriptEngine();
138 engine->onTrigger(context, session);
139 handleEngineNoLongerInUse(std::move(engine));
140 }
141 catch (const std::exception &exception) {
142 logger_->log_error("Caught Exception: %s", exception.what());
143 this->yield();
144 }
145 catch (...) {
146 logger_->log_error("Caught Exception");
147 this->yield();
148 }
149}
150
151// TODO(hunyadi): This is potentially not what we want. See https://issues.apache.org/jira/browse/MINIFICPP-1222
152std::shared_ptr<python::PythonScriptEngine> ExecutePythonProcessor::getScriptEngine() {

Callers

nothing calls this directly

Calls 4

log_errorMethod · 0.80
emptyMethod · 0.45
whatMethod · 0.45
yieldMethod · 0.45

Tested by

no test coverage detected