[pywin32-bugs] [ pywin32-Bugs-2858719 ] win32com can be used only one time in embedded python
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2009-09-14 22:24:16
|
Bugs item #2858719, was opened at 2009-09-15 03:40 Message generated for change (Settings changed) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2858719&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: com Group: None >Status: Closed >Resolution: Wont Fix Priority: 5 Private: No Submitted By: Cyrille Rey (cyr34) Assigned to: Nobody/Anonymous (nobody) Summary: win32com can be used only one time in embedded python Initial Comment: Hello all I embed python interpreters in a C++ program. For each script to execute I create a new interpreter. In this environment I can use the win32 extensions only one time. Here is a little piece of code to illustrate the problem: int main(int argc, char **argv) { Py_Initialize(); Py_SetProgramName(argv[0]); PyThreadState *save_tstate=PyThreadState_Swap(NULL); PyThreadState *state=Py_NewInterpreter(); int rc=PyRun_SimpleString("import sys\nimport win32com.client\nw=win32com.client.Dispatch("Word.Application")\nw.Visible = 1\n"); //this works well printf("%d\n",rc); Py_EndInterpreter(state); PyThreadState_Swap(save_tstate); state=Py_NewInterpreter(); rc=PyRun_SimpleString("import sys\nimport win32com.client\nw=win32com.client.Dispatch("Word.Application")\nw.Visible = 1\n"); //this and all further atemps will fail printf("%d\n",rc); Py_EndInterpreter(state); PyThreadState_Swap(save_tstate); ; } Here is the output of this little program: Traceback (most recent call last): File "<string>", line 8 (13), in <module> File "C:\cre\2009.2\techlog\PythonScripts\External261_x86\win32com\__init__.py", line 6, in <module> import pythoncom File "C:\cre\2009.2\techlog\PythonScripts\External261_x86\Lib\pythoncom.py", line 3, in <module> File "C:\cre\2009.2\techlog\PythonScripts\External261_x86\Lib\pywintypes.py", line 20, in __import_pywin32_system_module__ TypeError: 'NoneType' object is not callable I use Python 2.6 compiled with MSC v.8 32 bit (Intel)] on win32 with Pywin32- 214 Is there any way to overcome this problem? ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2009-09-15 08:23 Message: Sorry, this is a limitation of the PyGILState API used by pywin32; pywin32 will never be able to play with the multiple interpreter API, nor work correctly with multiple interpreter initializations and cleanups ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2858719&group_id=78018 |