Dispatching a Win32 COM in the background?
David LeBlanc
whisper at oz.net
Wed Jun 19 19:56:05 EDT 2002
Hmmm... and the run method of Background could be sitting on one end of a
Queue (Queue is thread-safe: see your python doc for details) that's
buffering the asyncronous calls on the speacher. The main task then just
stuffs a talk request into the queue and the Background processes it when it
gets to it.
David LeBlanc
Seattle, WA USA
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Peter Hansen
> Sent: Wednesday, June 19, 2002 16:47
> To: python-list at python.org
> Subject: Re: Dispatching a Win32 COM in the background?
>
>
> "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
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list