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 merrellb
Recipients jnoller, merrellb
Date 2008-12-23.06:40:33
SpamBayes Score 1.0155451e-05
Marked as misclassified No
Message-id <1230014436.88.0.00602843005324.issue4660@psf.upfronthosting.co.za>
In-reply-to
Content
Here are a few stabs at how this might be addressed.

1)  As originally suggested.  Allow task_done() to block waiting to 
acquire _unfinished_tasks.  This will allow the put() process to resume, 
release() _unfinished_tasks at which point task_done() will unblock.  No 
harm, no foul but you do lose some error checking (and maybe some 
performance?)

2)  One can't protect JoinableQueue.put() by simply acquiring _cond 
before calling Queue.put().  Fixed size queues will block if the queue 
is full, causing deadlock when task_done() can't acquire _cond.  The 
most obvious solution would seem to be reimplementing 
JoinableQueue.put() (not simply calling Queue.put()) and then inserting  self._unfinished_tasks.release() into a protected portion.  Perhaps:

    def put(self, obj, block=True, timeout=None):
        assert not self._closed
        if not self._sem.acquire(block, timeout):
            raise Full

        self._notempty.acquire()
        self._cond.acquire()
        try:
            if self._thread is None:
                self._start_thread()
            self._buffer.append(obj)
            self._unfinished_tasks.release()
            self._notempty.notify()
        finally:
            self._cond.release()
            self._notempty.release()

We may be able to get away with not acquiring _cond as _notempty would 
provide some protection.   However its relationship to get() isn't 
entirely clear to me so I am not sure if this would be sufficient.
History
Date User Action Args
2008-12-23 06:40:37merrellbsetrecipients: + merrellb, jnoller
2008-12-23 06:40:36merrellbsetmessageid: <1230014436.88.0.00602843005324.issue4660@psf.upfronthosting.co.za>
2008-12-23 06:40:36merrellblinkissue4660 messages
2008-12-23 06:40:33merrellbcreate