Skip to content

Commit

Permalink
Release the GIL after initializing tuber_resource
Browse files Browse the repository at this point in the history
This avoids a PyGILState_Check() failure when incref() is called on the imported registry object.
  • Loading branch information
arahlin committed Mar 7, 2024
1 parent 054c76f commit 8a2d5d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ int main(int argc, char **argv) {
/* Create a registry */
py::dict reg = py::eval("registry");

py::gil_scoped_release release;

/*
* Start webserver
*/
Expand All @@ -524,6 +522,8 @@ int main(int argc, char **argv) {
tr->set_allowing(MHD_HTTP_METHOD_POST, true);
ws->register_resource("/tuber", tr.get());

py::gil_scoped_release release;

/* If a valid webroot was provided, serve static content for other paths. */
try {
fr = std::make_unique<file_resource>(fs::canonical(webroot), max_age);
Expand Down

0 comments on commit 8a2d5d7

Please sign in to comment.