Windows/COM events/strange behavior

Krzysztof Czarnowski Krzysztof.Czarnowski at dgt-lab.com.pl
Mon Oct 22 13:47:16 CEST 2001


Hello,

Platform: WinNT4/Python2.1.1/win32all-140

The situation:
I run a script that, in one of its threads, receives events from a COM
object and occasionally does some polling to test if the event source is
alive. The script is being started from a DOS prompt. Module "threading" is
used. The COM event handler is constructed inside the thread and it lives in
a "single threaded appartment" (CoInitialize(), loop PumpWaitingMessages(),
CoUninitialize()).

Then, when I start Pythonwin it gets stuck! When I stop the script Pythonwin
seems to get released and starts (the window is displayed ...). Then I can
run the script again without problems.

Questions:
Has anyone encountered such behaviour? Explanation? Danger behind scenes?
Tips on how to change design to avoid such effects (use free threaded COM
model? native Win threads? ...?)

Thanks in advance,
Krzysztof








More information about the Python-list mailing list