This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JBernardo
Recipients JBernardo
Date 2013-05-28.03:40:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369712419.12.0.434704480843.issue18078@psf.upfronthosting.co.za>
In-reply-to
Content
If users could provide an inner lock for `threading.Condition` acquire when making a thread wait, it would allow for notifying a specific waiter.

Because of race conditions, using:

    cond.notify(1)

may not wake the thread I want. Also, I may not want to wake the first waiter at all.

So my proposal is something along the lines:



class Condition:
    ...

    def wait(self, timeout=None, lock=None):
        ...
        waiter = _allocate_lock() if lock is None else lock
        ...

    def notify_one(self, lock): 
        # Maybe could notify a list of locks?

        try:
            self._waiters.remove(lock)
        except ValueError:
            pass 
            # Maybe RuntimeError("Lock not waiting in this Condition")
        else:
            lock.release()
History
Date User Action Args
2013-05-28 03:40:19JBernardosetrecipients: + JBernardo
2013-05-28 03:40:19JBernardosetmessageid: <1369712419.12.0.434704480843.issue18078@psf.upfronthosting.co.za>
2013-05-28 03:40:19JBernardolinkissue18078 messages
2013-05-28 03:40:18JBernardocreate