Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33863
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.023 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'puts': 0.07; 'python': 0.09; 'called.': 0.09; 'subject:Why': 0.09; 'thread': 0.11; 'yet.': 0.13; 'inserting': 0.16; 'non-empty': 0.16; 'run.': 0.16; 'wrote:': 0.17; 'appears': 0.18; 'load': 0.19; 'import': 0.21; 'transfers': 0.23; 'header:In-Reply-To:1': 0.25; 'thanks!': 0.26; 'am,': 0.27; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'run': 0.28; 'cat': 0.29; 'queue': 0.29; 'objects': 0.29; 'fri,': 0.30; 'anybody': 0.32; 'could': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'likely': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'nov': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'should': 0.36; 'uses': 0.37; 'why': 0.37; 'item': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'most': 0.61; 'first': 0.61; 'chance': 0.61; 'become': 0.65; 'feeder': 0.84; 'skip:~ 60': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=fVrs89rUoYhl/R5sENULCiSfDkpK2sZrGYJTHg6YSj8=; b=hxvXcs8X0pWiyY2+JN+fSyACknKLr0jTgQsHtAVYh1bNNvoeAjE0OAmsd7oTKEpD0d S8ivG+vYqH8yZRvCZv+Sis0blV761h4PrTTJRstdt3cRB8yT8PuyGf5LXdWlh+zajWiQ b9siIzYq1qR2QgXsy5xBfthJBXZoYde1++euccyEOW/C3nhQ6PMxWcs22EvqENqArLiN bWMu/eEBUivJ1p8xaFO4QmYLdBVrp859rvZIGoImwimj9O16oLXz0QsZuJ0EOtPT3wva eGc2Q2dEi5GdR8lSUuY9pnGldNMFhFxnw1Bt4h7TodycKTaO8iC0F6NaRXDXnp9QVIWB Qazw== |
| MIME-Version | 1.0 |
| In-Reply-To | <f5b194cd-cf32-4c3b-a909-8c53a72a4b64@b12g2000vbg.googlegroups.com> |
| References | <f5b194cd-cf32-4c3b-a909-8c53a72a4b64@b12g2000vbg.googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 23 Nov 2012 11:53:31 -0700 |
| Subject | Re: Why queue.empty() returns False even after put() is called? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.240.1353696850.29569.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353696850 news.xs4all.nl 6869 [2001:888:2000:d::a6]:47120 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33863 |
Show key headers only | View raw
On Fri, Nov 23, 2012 at 9:57 AM, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> The empty() returns True even after put() has been called. Why it is
> empty when there some items in it? Could anybody help me understand
> it? Thanks!
>
> ~/linux/test/python/man/library/multiprocessing/Queue/empty$ cat
> main.py
> #!/usr/bin/env python
>
> import multiprocessing
>
> queue = multiprocessing.Queue()
> print queue.empty()
> queue.put(['a', 'b'])
> queue.put(['c', 'd'])
> print queue.empty()
According to the docs, the Queue uses a background thread to load data into it:
When a process first puts an item on the queue a feeder thread is
started which transfers objects from a buffer into the pipe.
Most likely it still appears to be empty because this thread has not
had a chance to run yet. If you try inserting a time.sleep() call,
you should see the queue become non-empty once the background thread
has run.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Why queue.empty() returns False even after put() is called? Peng Yu <pengyu.ut@gmail.com> - 2012-11-23 08:57 -0800 Re: Why queue.empty() returns False even after put() is called? MRAB <python@mrabarnett.plus.com> - 2012-11-23 18:53 +0000 Re: Why queue.empty() returns False even after put() is called? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-23 11:53 -0700
csiph-web