TODO(hunyadi): This is potentially not what we want. See https://issues.apache.org/jira/browse/MINIFICPP-1222
| 150 | |
| 151 | // TODO(hunyadi): This is potentially not what we want. See https://issues.apache.org/jira/browse/MINIFICPP-1222 |
| 152 | std::shared_ptr<python::PythonScriptEngine> ExecutePythonProcessor::getScriptEngine() { |
| 153 | std::shared_ptr<python::PythonScriptEngine> engine; |
| 154 | // Use an existing engine, if one is available |
| 155 | if (script_engine_q_.try_dequeue(engine)) { |
| 156 | logger_->log_debug("Using available [%p] script engine instance", engine.get()); |
| 157 | return engine; |
| 158 | } |
| 159 | engine = createEngine<python::PythonScriptEngine>(); |
| 160 | logger_->log_info("Created new [%p] script engine instance. Number of instances: approx. %d / %d.", engine.get(), script_engine_q_.size_approx(), getMaxConcurrentTasks()); |
| 161 | if (engine == nullptr) { |
| 162 | throw std::runtime_error("No script engine available"); |
| 163 | } |
| 164 | return engine; |
| 165 | } |
| 166 | |
| 167 | void ExecutePythonProcessor::handleEngineNoLongerInUse(std::shared_ptr<python::PythonScriptEngine>&& engine) { |
| 168 | // Make engine available for use again |