'Indicate that a thread that was putting into this queue has
exited. If this is the last thread using the queue, the queue
is poisoned.'

def release(self):

    with self.mutex:
        self.nthreads -= 1
        assert (self.nthreads >= 0)
        if (self.nthreads == 0):
            self.poisoned = True
            _old_get = self._get
            def _get():
                out = _old_get()
                if (not self.queue):
                    _invalidate_queue(self, POISON, False)
                return out
            if self.queue:
                self._get = _get
            else:
                _invalidate_queue(self, POISON, False)
