Skip to content

Commit

Permalink
Release GIL during server.stop() to allow request release callbacks t…
Browse files Browse the repository at this point in the history
…o complete during shutdown
  • Loading branch information
rmccorm4 committed Jul 17, 2024
1 parent 8153c2e commit 41ac76b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/tritonserver/_c/tritonserver_pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,18 @@ class PyServer : public PyWrapper<struct TRITONSERVER_Server> {
owned_ = true;
}

void Stop() const { ThrowIfError(TRITONSERVER_ServerStop(triton_object_)); }
void Stop() const
{
// ServerStop is blocking for the duration of the server exit timeout, so
// ensure to release the GIL. This can allow request release callbacks
// to be interleaved while server is waiting for live requests/models
// to complete. Without releasing GIL, this function may acquire the GIL
// first and block the Triton request from being released/freed, thus
// blocking the server's shutdown in a circular manner thinking a model is
// still alive.
py::gil_scoped_release release;
ThrowIfError(TRITONSERVER_ServerStop(triton_object_));
}

void RegisterModelRepository(
const std::string& repository_path,
Expand Down

0 comments on commit 41ac76b

Please sign in to comment.