Skip to content

Commit

Permalink
executeStream already does GIL release, we don't need to do it. pybin…
Browse files Browse the repository at this point in the history
…d11 does GIL acquire with every method call so we don't need to be doing that either
  • Loading branch information
hobu committed Jan 4, 2024
1 parent dd75a38 commit 6bcdde9
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions pdal/libpdalpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace pdal {
};

std::vector<py::dict> getDrivers() {
py::gil_scoped_acquire acquire;
std::vector<py::dict> drivers;

pdal::StageFactory f(false);
Expand Down Expand Up @@ -59,7 +58,6 @@ namespace pdal {
};

py::object getOptions() {
py::gil_scoped_acquire acquire;
py::object json = py::module_::import("json");
py::dict stageOptions;

Expand Down Expand Up @@ -94,7 +92,6 @@ namespace pdal {
};

std::vector<py::dict> getDimensions() {
py::gil_scoped_acquire acquire;
py::object np = py::module_::import("numpy");
py::object dtype = np.attr("dtype");
std::vector<py::dict> dims;
Expand All @@ -112,13 +109,11 @@ namespace pdal {

std::string getReaderDriver(std::filesystem::path const& p)
{
py::gil_scoped_acquire acquire;
return StageFactory::inferReaderDriver(p.string());
}

std::string getWriterDriver(std::filesystem::path const& p)
{
py::gil_scoped_acquire acquire;
return StageFactory::inferWriterDriver(p.string());
}

Expand All @@ -142,7 +137,6 @@ namespace pdal {
}

py::object getMetadata() {
py::gil_scoped_acquire acquire;
py::object json = py::module_::import("json");

std::stringstream strm;
Expand Down Expand Up @@ -175,12 +169,7 @@ namespace pdal {
}

point_count_t executeStream(point_count_t streamLimit) {
point_count_t response(0);
{
py::gil_scoped_release release;
response = getExecutor()->executeStream(streamLimit);
}
return response;
return getExecutor()->executeStream(streamLimit);
}

std::unique_ptr<PipelineIterator> iterator(int chunk_size, int prefetch) {
Expand All @@ -190,7 +179,6 @@ namespace pdal {
}

void setInputs(std::vector<py::array> ndarrays) {
py::gil_scoped_acquire acquire;
_inputs.clear();
for (const auto& ndarray: ndarrays) {
PyArrayObject* ndarray_ptr = (PyArrayObject*)ndarray.ptr();
Expand All @@ -209,7 +197,6 @@ namespace pdal {
std::string getSrsWKT2() { return getExecutor()->getSrsWKT2(); }

py::object getQuickInfo() {
py::gil_scoped_acquire acquire;
py::object json = py::module_::import("json");

std::string response;
Expand Down Expand Up @@ -275,7 +262,6 @@ namespace pdal {
void delExecutor() { _executor.reset(); }

PipelineExecutor* getExecutor() {
py::gil_scoped_acquire acquire;
if (!_executor)
_executor.reset(new PipelineExecutor(getJson(), _inputs, _loglevel));
return _executor.get();
Expand Down

0 comments on commit 6bcdde9

Please sign in to comment.