Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74537

Re: multiprocessing problem: queue.get() not finding pushed values

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <charleshixsn@earthlink.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'programmer': 0.03; 'subject:not': 0.03; '16,': 0.03; 'else:': 0.03; 'operator': 0.03; 'read.': 0.03; 'win32': 0.03; 'broken': 0.04; 'causing': 0.04; 'digest': 0.04; 'receives': 0.04; 'resulting': 0.04; 'skip:[ 20': 0.04; 'syntax': 0.04; 'value,': 0.04; 'argument': 0.05; 'explicitly': 0.05; 'handler': 0.05; 'importing': 0.05; 'interpreter': 0.05; 'messages.': 0.05; 'output': 0.05; 'represents': 0.05; 'retrieved': 0.05; 'root': 0.05; 'string.': 0.05; 'subsequent': 0.05; '(using': 0.07; 'amounts': 0.07; 'args': 0.07; 'attribute': 0.07; 'cache': 0.07; 'context': 0.07; 'defaults': 0.07; 'element': 0.07; 'explicit': 0.07; 'finally:': 0.07; 'float': 0.07; 'ignored': 0.07; 'initialize': 0.07; 'interpreter.': 0.07; 'matches': 0.07; 'memory.': 0.07; 'method.': 0.07; 'modified': 0.07; 'modify': 0.07; 'needed,': 0.07; 'none,': 0.07; 'puts': 0.07; 'referring': 0.07; 'remaining': 0.07; 'returned.': 0.07; 'skip:` 10': 0.07; 'socket': 0.07; 'stops': 0.07; 'sys': 0.07; 'test,': 0.07; 'tries': 0.07; 'variables': 0.07; 'string': 0.09; 'boundaries': 0.09; 'caching,': 0.09; 'callback': 0.09; 'calls.': 0.09; 'clause': 0.09; 'cleanup': 0.09; 'constructor': 0.09; 'contexts': 0.09; 'converted': 0.09; 'created,': 0.09; 'creator': 0.09; 'default.': 0.09; 'defines': 0.09; 'emulate': 0.09; 'exception.': 0.09; 'executable': 0.09; 'executed': 0.09; 'exit': 0.09; 'exits': 0.09; 'explanation': 0.09; 'false,': 0.09; 'false.': 0.09; 'filename': 0.09; 'finished.': 0.09; 'functioning': 0.09; 'if,': 0.09; 'implemented.': 0.09; 'implements': 0.09; 'imported': 0.09; 'indicates': 0.09; 'inherited': 0.09; 'insertion': 0.09; 'instance.': 0.09; 'item,': 0.09; 'key.': 0.09; 'machines.': 0.09; 'means,': 0.09; 'method,': 0.09; 'method:': 0.09; 'methods,': 0.09; 'mixed': 0.09; 'module)': 0.09; 'msg': 0.09; 'namespace': 0.09; 'newly': 0.09; 'none)': 0.09; 'obj': 0.09; 'objects,': 0.09; 'override': 0.09; 'performs': 0.09; 'prevents': 0.09; 'propagate': 0.09; 'raises': 0.09; 'read-only': 0.09; 'referenced': 0.09; 'restriction': 0.09; 'shifting': 0.09; 'skip:$ 20': 0.09; 'skip:/ 10': 0.09; 'specified,': 0.09; 'sphinx': 0.09; 'strings.': 0.09; 'structure,': 0.09; 'supported,': 0.09; 'terminated': 0.09; 'try:': 0.09; 'type,': 0.09; 'used.': 0.09; 'variable,': 0.09; 'variant': 0.09; 'windows,': 0.09; 'wrapped': 0.09; 'wrapper': 0.09; '\xe2\x80\x94': 0.09; 'cutting': 0.91; 'demand': 0.91; 'drops': 0.91; 'exchanging': 0.91; 'forgotten': 0.91; 'killed': 0.91; 'processes,': 0.91; 'task,': 0.91; 'whereas': 0.91; 'children.': 0.93; 'suited': 0.93; 'directly.': 0.95; 'period.': 0.95; 'interrupted': 0.96; 'serious': 0.97
Date Tue, 15 Jul 2014 22:47:10 -0700
From Charles Hixson <charleshixsn@earthlink.net>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0
MIME-Version 1.0
To python-list@python.org, Chris Angelico <rosuav@gmail.com>
Subject Re: multiprocessing problem: queue.get() not finding pushed values
References <53C58FC8.2030202@earthlink.net> <CAPTjJmoU2qbeMamfHeSkWRrqm3Z-u0fxdcP1O-vp-zZCawkZKQ@mail.gmail.com>
In-Reply-To <CAPTjJmoU2qbeMamfHeSkWRrqm3Z-u0fxdcP1O-vp-zZCawkZKQ@mail.gmail.com>
Content-Type multipart/alternative; boundary="------------060100080806020202080009"
X-Mailman-Approved-At Wed, 16 Jul 2014 08:59:13 +0200
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11866.1405493954.18130.python-list@python.org> (permalink)
Lines 4401
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1405493954 news.xs4all.nl 2885 [2001:888:2000:d::a6]:37876
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74537

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 07/15/2014 09:26 PM, Chris Angelico wrote:
> On Wed, Jul 16, 2014 at 6:32 AM, Charles Hixson
> <charleshixsn@earthlink.net> wrote:
>> from queue import Empty, Full
> Not sure what this is for, you never use those names (and I don't have
> a 'queue' module to import from). Dropped that line. In any case, I
> don't think it's your problem...
>
>> if __name__ == "__main__":
>>      dbw    =    DBW(DBW_to, DBW_from)
>>      dbw.run()
>>      DBW_to.put(Msg("a", 1, wrd) )
>>      DBW_to.put(Msg("b", 2, wrd) )
>>      DBW_to.put(Msg("c", 0, None) )
> ... which is here. You're not starting a subprocess; you're simply
> calling a method, so it runs synchronously. When you call .run(), it
> runs the "subprocess" to completion, which then bombs because the
> queue's empty, and then never gets to putting anything onto it. Change
> that .run() to .start() and it'll do as you expect, except that as
> part of cutting the example down you seem to have omitted the
> definition of wrd. I changed that to a quoted string and it works:
>
> # chomp unchanged code ...
> if __name__ == "__main__":
>      dbw    =    DBW(DBW_to, DBW_from)
>      dbw.start()
>      DBW_to.put(Msg("a", 1, 'wrd') )
>      DBW_to.put(Msg("b", 2, 'wrd') )
>      DBW_to.put(Msg("c", 0, None) )
>
> rosuav@sikorsky:~$ python test7a.py
> msg = Msg(act='a', id=1, vals='wrd')
>
> Hope that helps!
>
> ChrisA
Thank you.  I had forgotten that one wasn't supposed to call run directly.
FWIW, I import Empty and Full because the multiprocessor documentations 
says in


      17.2.2.2. Pipes and Queues

Note

multiprocessing <cid:part1.05080901.05000005@earthlink.net> uses the 
usual queue.Empty <cid:part2.06060100.00020506@earthlink.net> and 
queue.Full <cid:part3.01060608.01040702@earthlink.net> exceptions to 
signal a timeout. They are not available in the multiprocessing 
<cid:part1.05080901.05000005@earthlink.net> namespace so you need to 
import them from queue <cid:part5.09090108.07050309@earthlink.net>.

They aren't used in the stripped down test, but they are used in the 
real code

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: multiprocessing problem: queue.get() not finding pushed values Charles Hixson <charleshixsn@earthlink.net> - 2014-07-15 22:47 -0700

csiph-web