Files
Giacomo Vercesi de75d94597 {Pipe,Analysis}Run: release Python GIL
Move out of the `runPipe`/`runAnalysis` functions the logic that
extracts the container from the vector type. This logic is now
delegated to `containerVectorToTuple` which converts the vector type to
a tuple of references. This allows python's `run{Pipe,Analysis}` to
safely call `nanobind::gil_scoped_release` which releases the GIL for
the entire duration of the `runPipe`/`runAnalysis` execution.
2025-11-26 14:59:43 +01:00

35 lines
1.1 KiB
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "nanobind/nanobind.h"
#include "revng/PipeboxCommon/Helpers/AnalysisRunner.h"
#include "revng/PipeboxCommon/Helpers/Python/Helpers.h"
#include "revng/PipeboxCommon/Model.h"
namespace revng::pypeline::helpers::python {
template<typename T>
inline llvm::Error runAnalysis(T &Handle,
nanobind::handle_t<Model> TheModel,
nanobind::list Containers,
Request Incoming,
llvm::StringRef Configuration) {
Model *CppModel = nanobind::cast<Model *>(TheModel);
auto ContainerTuple = containerVectorToTuple<T>(Containers);
{
nanobind::gil_scoped_release X;
return revng::pypeline::helpers::runAnalysis(Handle,
*CppModel,
Incoming,
Configuration,
ContainerTuple);
}
}
} // namespace revng::pypeline::helpers::python