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 ncoghlan
Recipients kdlucas, ncoghlan, pitrou, rhettinger
Date 2012-04-04.03:56:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333511768.18.0.125428097694.issue9634@psf.upfronthosting.co.za>
In-reply-to
Content
The function below is the workaround I plan to use based on the undocumented-but-public Thread attributes that relate to the task queue (it's essentially just a combination of Queue.join() with the existing structure of the Queue.get() implementation):

  def join_queue(q, timeout=None):
      q.all_tasks_done.acquire()
      try:
          if timeout is None:
              while q.unfinished_tasks:
                  self.all_tasks_done.wait()
          elif timeout < 0:
              raise ValueError("'timeout' must be a positive number")
          else:
              endtime = _time() + timeout
              while q.unfinished_tasks:
                  remaining = endtime - _time()
                  if remaining <= 0.0:
                      raise Pending
                  self.all_tasks_done.wait(remaining)
      finally:
          q.all_tasks_done.release()
History
Date User Action Args
2012-04-04 03:56:08ncoghlansetrecipients: + ncoghlan, rhettinger, pitrou, kdlucas
2012-04-04 03:56:08ncoghlansetmessageid: <1333511768.18.0.125428097694.issue9634@psf.upfronthosting.co.za>
2012-04-04 03:56:07ncoghlanlinkissue9634 messages
2012-04-04 03:56:07ncoghlancreate