Python multithreading problem
Serge Orlov
Serge.Orlov at gmail.com
Sun Mar 26 18:18:50 EST 2006
abhinav wrote:
> //A CRAWLER IMPLEMENTATION
> please run this prog. on the shell and under the control of debugger
> when this prog. is run normally the prog. does not terminate .It
> doesn't come out of the cond. if c<5: so this prog. continues
> infinitely
How do you know? Have you waited *infinitely* ;)
> if c<5:
> self.stdmutex.acquire()
The problem you have a lot of threads that has already checked c < 5
condition but has not acquired the lock yet. Besides you have another
problem: if a thread raises an exception you don't release the lock.
Why don't you use Queue module for sane thread management?
Serge.
More information about the Python-list
mailing list