Dispatching a Win32 COM in the background?

Peter Hansen peter at engcorp.com
Wed Jun 19 19:46:32 EDT 2002


"Steven M. Castellotti" wrote:
> 
> 2) Make the call inside a thread which produces the same effect.

This might work (I don't know anything about COM though).  Try putting
your own code inside the run method of a thread:

import threading
class Background(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        print 'Starting'
        pass   # your own code goes here
        print 'Done'

>>> b = Background()
>>> b.start()
Starting
<possibly a pause here?>
Done

If at this point you get a >>> prompt back right away, but the
speech generation is carrying on "in the background" then you're
all set.  Make sure you do this with code you've already tested
outside of the thread, so you'll know that any failure is not
the fault of your own code...

-Peter



More information about the Python-list mailing list