On Aug 6, 1:33 pm, Nikolaus Rath <[EMAIL PROTECTED]> wrote:
> Carl Banks <[EMAIL PROTECTED]> writes:
> > Freaky... I just posted nearly this exact solution.
>
> > I have a couple comments. First, the call to acquire should come
> > before the try block. If the acquire were to fail, you wouldn't want
> > to release the lock on cleanup.
>
> > Second, you need to change notify() to notifyAll(); notify alone won't
> > cut it. Consider what happens if you have two threads waiting for
> > keys A and B respectively. When the thread that has B is done, it
> > releases B and calls notify, but notify happens to wake up the thread
> > waiting on A. Thus the thread waiting on B is starved.
>
> You're right. Thanks for pointing it out.
>
There's also less chance of deadlock if the files are always locked in
the same order, ie if you sort the files by, say, name, don't lock a
file if one earlier in the sorted list is already locked.
--
http://mail.python.org/mailman/listinfo/python-list