View Full Version : running into a thread limit

10-19-2004, 04:25 PM
Hi guys,

I found a problem having to do with threads. I am not sure if this is a bug or if I am doing something wrong.

Basically, after executing a certain number of threads or calling functions that use threads (I am guessing Vizard's <multimedia>.play() uses a thread and I know viz.director() starts a thread), Vizard refuses to create or run any more threads. I load many multimedia files into my application (a dozen .avi and a dozen .wav) and I think that may be the cause. After certain number of calls <multimedia>.play() seems to generate the following error:
FAILED (hr=0x80007000e) in pMC->Run()
Also, if I load two dozen multimedia files and then start creating threads using python's thread library ( example: thread.start_new_thread(Animate, ()) ), eventually I get an error that says something like, "Failed to create thread" even if I don't call <multimedia>.play() at all.

Is this a bug in Vizard?


10-20-2004, 10:57 AM

I'm going to test this out here. How many times do you run a director function? When you hit the thread limit, are you not able to run director functions also? Is the thread limit consistent (i.e. does it always stop working when you create a certain amount of media objects)?

10-20-2004, 11:49 AM
Hi Farshizzo,

Yes, viz.director() stops also even without a single execution of <multimedia>.play() and <multimedia>.play() eventually stops working without any viz.director() calls.

Try running the following code:

import thread
import time
import viz

def myfunc():
sum = 0
for i in range(100000):
sum = sum + i
print 'sum is:', sum

for i in range(100):
thread.start_new_thread(myfunc, ())

On my computer, which by the way has plenty of memory, I only get 47 outputs of "sum is 4999950000" even though I create 100 threads and I get a message in red that says, "error: can't start new thread". You can replace the last line above with viz.director(myfunc) and you will get the same result except that no error message will be displayed.


10-20-2004, 12:53 PM

Thanks for the code sample, I also get an error here at thread 47. I've made a change to Vizard and now the sample works fine, even with director functions. However, I haven't tested it with media files. If you just add 30 media files and try to play them all, do you get an error?

10-27-2004, 03:59 PM
Thanks for fixing the problem. Both the threads and multimedia files work fine now.