I am trying to debug a problem using the ctypes shell from Windows DLLs and have noticed differences when I run tests through an interactive shell (python or ipython) and when I run scripts non-interactively.
I was wondering if there is any explanation for the differences that I see here?
In particular, when I run a simple test interactively, the DLL call will hang and never return, where exactly the same code as the script will not demonstrate this problem.
To be more clear what I mean here, imagine you have the following code
from foobar import bar, foo bar(foo(1,2,3))
When you insert a file, say, โmyfoo.pyโ and excecuted through โpython myfoo.pyโ, the above code executes as expected. However, if you enter the above into the python / ipython shell, the code behaves differently (in my case it hangs when the ctypes.WinDLL function is called)
Additional information:
I use the same interpreter and the same PYTHONPATH in both cases. The wrapped DLL is Canon EDSDKv2.9, an SDK for remotely controlling cameras. It always hangs in a DLL, not in python code.
Upon initialization, my EDSDK wrapper launches a thread whose execution method is as follows:
def run(self): sys.coinit_flags = 0
The purpose of these threads is to initialize the SDK, send messages, and allow other threads to call wrapped methods.
Note: in previous versions of EDSDK, this worked both interactively and interactively. My current problem only occurs in the latest version of EDSDK.
I suspect that this may be due to streams (hence the fragment), but cannot find any information on the Internet to support my suspicions.
So, does anyone know of any differences when starting python interactively and not interactively? Perhaps related to window threads? Any help, even wild guesses, will be appreciated on this subject, because I'm completely at a standstill! :)