adamdebreceni commented on a change in pull request #1222:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1222#discussion_r763973217



##########
File path: extensions/script/python/ExecutePythonProcessor.cpp
##########
@@ -50,39 +50,72 @@ core::Property 
ExecutePythonProcessor::ModuleDirectory(core::PropertyBuilder::cr
   ->withDefaultValue("")
   ->build());
 
-core::Relationship ExecutePythonProcessor::Success("success", "Script 
successes");
-core::Relationship ExecutePythonProcessor::Failure("failure", "Script 
failures");
+core::Relationship ExecutePythonProcessor::Success("success", "Script 
succeeds");
+core::Relationship ExecutePythonProcessor::Failure("failure", "Script fails");
 
 void ExecutePythonProcessor::initialize() {
-  setSupportedProperties({
-    ScriptFile,
-    ScriptBody,
-    ModuleDirectory
-  });
-  setAcceptAllProperties();
-  setSupportedRelationships({
-    Success,
-    Failure
-  });
-}
+  if (getProperties().empty()) {
+    setSupportedProperties({
+      ScriptFile,
+      ScriptBody,
+      ModuleDirectory
+    });
+    setAcceptAllProperties();
+    setSupportedRelationships({
+      Success,
+      Failure
+    });
+  }
+
+  if (processor_initialized_) {
+    logger_->log_debug("Processor has already been initialized, returning...");
+    return;
+  }
 
-void ExecutePythonProcessor::onSchedule(const 
std::shared_ptr<core::ProcessContext> &context, const 
std::shared_ptr<core::ProcessSessionFactory>& /*sessionFactory*/) {
   python_logger_ = 
core::logging::LoggerFactory<ExecutePythonProcessor>::getAliasedLogger(getName());
 
   getProperty(ModuleDirectory.getName(), module_directory_);
-
   appendPathForImportModules();
-  loadScript();
 
-  if (script_to_exec_.empty()) {
-    throw std::runtime_error("Neither Script Body nor Script File is available 
to execute");
+  try {
+    loadScript();
+  } catch(const std::runtime_error&) {
+    logger_->log_warn("Could not load python script while initializing. In 
case of non-native python processor this is normal and will be done in the 
schedule phase.");

Review comment:
       I see, that makes sense, could you add this reason as a comment?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to