Thanks for the information. My test looks like this right now. I have two plugins which, when loaded separately, work. But when both are loaded, I get AccessVioletion messages from python37.dll. The init code for both dlls is this:
cpp_init_code = f'''#include <Python.h> #include "PluginInterface.h" PyMODINIT_FUNC PyInit_{PLUGIN_NAME}(void); BOOL APIENTRY DllMain( HANDLE hModule, DWORD reasonForCall, LPVOID /* lpReserved */ ) {{ switch ( reasonForCall ) {{ case DLL_PROCESS_ATTACH: PyImport_AppendInittab("{PLUGIN_NAME}", &PyInit_{PLUGIN_NAME}); Py_InitializeEx(Py_IsInitialized() ? 0 : 1); PyImport_ImportModule("{PLUGIN_NAME}"); break; case DLL_PROCESS_DETACH: Py_Finalize(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; }} return TRUE; }}''' This is written to a plugininit.cpp file and then built via setup.py with distutil, cython and VS2017. According to the docs PyImport_AppendInittab should be called before Py_Initialize but I can't call Py_Initialize the second time as it would remove what was initialized by the first dll. And using PyImport_ImportModule on the second dll only does not work either. So that is were I'm trapped. Thank you Eren Am Do., 13. Feb. 2020 um 07:26 Uhr schrieb R.Wieser <address@not.available>: > Eko, > > > which needs also access to python3.dll but cannot load it itself as it > has > > been already loaded by plugin1 > > > > Is such a scenario actually possible? > > Yes. > > Normally a DLL can be loaded in as many processes (and threads thereof) as > you like. > > However, it is possible that the DLLs initialisation contains code to > check > if something it needs is available*, and if not directly exit. > > *like if it can access certain I/O - if the first DLL instance "takes > posession" the second DLL instance wil fail. Than again, this can also > happen when using two totally different plugin DLLs. > > tl;dr: > Yes, but not likely. > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list