Dispatching a Win32 COM in the background?

Steven M. Castellotti SteveC at nospam.innocent.com
Fri Jun 21 15:06:49 EDT 2002

On Thu, 20 Jun 2002 20:22:40 -0500, Peter Hansen wrote:

> "Steven M. Castellotti" wrote:
>> Thanks a lot guys, your suggestions have worked perfectly!
>>         Just for the record, here's what the full implementation looks
>>         like.
> Beautiful... thanks for the followup Steven.  I especially like your use
> of deferred imports to speed up initial program loading.

	Thank you for the compliment. Speeding up program loading by deferring
imports is really only a side bonus though. The program is actually
cross-platfrom, meant to be run under both Linux and Windows. Since I'm
making calls to the Festival TTS program under linux, I have a seperate
class object, depending on what gets returned by os.name.

> [...]
>>       if not(self.text_queue.empty()):
>>          text = self.text_queue.get()
>>          speech.Speak(text)
>>          time.sleep(.001)
> Note that the time.sleep() as shown above is doing nothing useful for
> you.  I suspect you had it unindented but your posting probably used
> tabs and spaces which makes it hard to see properly on some readers.
> The reason it does nothing useful is that Python will automatically
> switch between different threads every so often anyway, so the concept
> of giving up the CPU for what amounts to a tiny fraction of a second is
> somewhat unnecessary.

	That makes sense to me, I think I'll remove the time.sleep() call. The
reason I had it in there in the first place (and it was unindented) was
because I have a similar call in a loop to Pygame (a wrapper to the SDL
graphics library), which is not multithreaded. I needed the calls in the
Pygame loop in order to prevent CPU usage from sitting at 100%, but if
multithreading will happen properly without it, I won't use it.


Steve Castellotti
SteveC (at) innocent.com

More information about the Python-list mailing list