[python-win32] Threads in COM not given time to execute?

Marcus Low marcus at internetnowasp.net
Mon Mar 31 10:48:30 CEST 2008


Hi,

I am testing a COM component, when i execute it under pythonwin idle and single stepping F10 to "SmtpMail.Start()" :

    SmtpMail = win32com.client.Dispatch("SomeSMTPCom")
    SmtpMail.Start()    
    
I can telnet to 127.0.0.1 25 and get a proper SMTP response


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
before allowing the function to quit to that SmtpMail.Start() can run as long as it want :-

def MainEntry () :
    global FlagToStop

    SmtpMail = win32com.client.Dispatch("SomeSMTPCom")
    SmtpMail.Start()    
    thread.start_new(CheckForQuit,(0,))
    
    while FlagToStop == False :
        win32api.Sleep(1000)      # i tried os.sleep(0), pass but the uses 50% of cpu

    SmtpMail.Stop()
    

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
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
get the time to execute and thus could not respond.

Am i missing out some basic steps here?


Marcus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080331/47e3ea3f/attachment.htm 


More information about the python-win32 mailing list