<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16609" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Found the reason. The COM component in this case
somehow depends on the windows message pump.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> <BR> while FlagToStop ==
False :<BR>
win32gui.PumpMessages();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Solved the issue.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Marcus.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=marcus@internetnowasp.net
href="mailto:marcus@internetnowasp.net">Marcus Low</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=python-win32@python.org
href="mailto:python-win32@python.org">'Python-Win32 List'</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, March 31, 2008 4:48
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [python-win32] Threads in COM
not given time to execute?</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am testing a COM component, when i execute it
under pythonwin idle and single stepping F10 to "SmtpMail.Start()"
:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> SmtpMail =
win32com.client.Dispatch("SomeSMTPCom")<BR>
SmtpMail.Start() <BR></FONT><FONT face=Arial
size=2> <BR>I can telnet to 127.0.0.1 25 and get a proper
SMTP response</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But when i run the program it just quits so i am
assuming SmtpMail.Start() does not block. So i added a function to wait for an
event</FONT></DIV>
<DIV><FONT face=Arial size=2>before allowing the function to quit to that
SmtpMail.Start() can run as long as it want :-</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>def MainEntry () :<BR> global
FlagToStop</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> SmtpMail =
win32com.client.Dispatch("SomeSMTPCom")<BR>
SmtpMail.Start() <BR>
thread.start_new(CheckForQuit,(0,))<BR>
<BR> while FlagToStop == False
:<BR>
win32api.Sleep(1000) # i tried os.sleep(0), pass
but the uses 50% of cpu</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
SmtpMail.Stop()<BR> <BR></FONT></DIV>
<DIV><FONT face=Arial size=2>i have confirmed that the it will loop in "While
FlagToStop ..." however when i telnet 127.0.0.1 25, it gets connected but i
don't get a reply from the COM which</FONT></DIV>
<DIV><FONT face=Arial><FONT size=2>is a STMP component. I can get a response
if i use single step to where ".Start()" but if i just run the program i get
this feeling that the COM object here doesnt</FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2>get the time to execute and thus could
not respond.</FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT size=2>Am i missing out some basic steps
here?</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Marcus.</FONT></DIV>
<DIV><FONT face=Arial><FONT size=2></FONT> </DIV></FONT>
<P>
<HR>
<P></P>_______________________________________________<BR>python-win32 mailing
list<BR>python-win32@python.org<BR>http://mail.python.org/mailman/listinfo/python-win32<BR></BLOCKQUOTE></BODY></HTML>