2

I have a Windows routine that uses the Python Library. I started out with 3.6.5 and a static library. Got it to work. Moved to a .dll Python library. Also works. Moved to 3.7. Does NOT work. It hangs when I attempt to close the embedded Python with a call to PyGILState_Ensure() and then Py_Finalize(). It hangs on the call to PyGILState_Ensure().

So I backed off a bit and went with Python 3.6.6. This also works. Same code, just a different library. Has anyone else noticed a change in behavior of the GIL stuff for Python 3.7? In the documentation, they mentioned they made some changes with the GIL.

Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96
Jiminion
  • 5,080
  • 1
  • 31
  • 54

1 Answers1

1

If you are using python 3.6 and below you need to call PyEval_InitThreads() You no longer have to do this in python 3.7, Py_initialize() does it for you. Could be your problem?

  • I don't call that. Only calls I make before Py_Initialize() are: Py_IsInitialized(), Py_GetPath(), Py_SetPath(), and PyImport_AppendInittab(). [PyImport_AppendInittab() calls PyModule_Create(), but I don't think it worked even when I took out the call to PyImport_AppendInittab().] – Jiminion Jul 18 '18 at 13:21
  • Oops, looks like Py_GetPath() should not be called before Py_Initialize(). I wonder if that is new... – Jiminion Jul 18 '18 at 13:23
  • You should call PyImport_AppendInittab() then py_Intialize – Eric Kleckner Jul 18 '18 at 16:25