| 99 | } |
| 100 | |
| 101 | void ExecutePythonProcessor::onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory>& /*sessionFactory*/) { |
| 102 | if (!valid_init_) { |
| 103 | throw std::runtime_error("Could not correctly initialize " + getName()); |
| 104 | } |
| 105 | try { |
| 106 | reloadScriptIfUsingScriptFileProperty(); |
| 107 | if (script_to_exec_.empty()) { |
| 108 | throw std::runtime_error("Neither Script Body nor Script File is available to execute"); |
| 109 | } |
| 110 | std::shared_ptr<python::PythonScriptEngine> engine = getScriptEngine(); |
| 111 | |
| 112 | engine->eval(script_to_exec_); |
| 113 | engine->onSchedule(context); |
| 114 | |
| 115 | handleEngineNoLongerInUse(std::move(engine)); |
| 116 | } |
| 117 | catch (const std::exception& exception) { |
| 118 | logger_->log_error("Caught Exception: %s", exception.what()); |
| 119 | } |
| 120 | catch (...) { |
| 121 | logger_->log_error("Caught Exception"); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | void ExecutePythonProcessor::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) { |
| 126 | if (!valid_init_) { |