Skip to content

Commit

Permalink
DISPATCH-2360: call Py_Initialize before any other python C (#1671)
Browse files Browse the repository at this point in the history
This is a backport of a skupper-router fix from

* skupperproject/skupper-router#1307
  • Loading branch information
jiridanek committed Dec 2, 2023
1 parent c0ccdb1 commit ad53d67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python_embedded.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ void qd_python_initialize(qd_dispatch_t *qd, const char *python_pkgdir)
{
log_source = qd_log_source("PYTHON");
dispatch = qd;
if (python_pkgdir)
dispatch_python_pkgdir = PyUnicode_FromString(python_pkgdir);

Py_Initialize();
#if PY_VERSION_HEX < 0x03070000
PyEval_InitThreads(); // necessary for Python 3.6 and older versions
#endif
if (python_pkgdir)
dispatch_python_pkgdir = PyUnicode_FromString(python_pkgdir);
qd_python_setup();
PyEval_SaveThread(); // drop the Python GIL; we will reacquire it in other threads as needed
}
Expand Down

0 comments on commit ad53d67

Please sign in to comment.