Queue can result in nested monitor deadlock

Paul McGuire ptmcg at austin.rr._bogus_.com
Mon Apr 17 14:22:35 EDT 2006


"Jonathan Amsterdam" <jbamsterdam at gmail.com> wrote in message
news:1145292096.906390.254280 at e56g2000cwe.googlegroups.com...
> If you don't want to call it deadlock, fine, but the program execution
> I describe will make no progress to the end of time. Thread 2 can never
> put anything in the queue, because Thread 1 holds M, and Thread 1 will
> never release M because that can only happen if someone puts something
> on the queue.
>

Ah, I get it now, and yes as you describe it, this is a deadlock.  But why
do you need both mutex M and a Queue, then?  You should release M before
calling Queue.get().  Then if you need to, you should reacquire it
afterward.

-- Paul





More information about the Python-list mailing list