Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'exception': 0.03; 'interpreter': 0.04; 'mrab': 0.05; '21,': 0.07; 'exception.': 0.07; 'raised': 0.07; 'seemed': 0.07; 'python': 0.09; 'occasionally': 0.09; 'snippet': 0.09; 'throws': 0.09; 'to:addr:comp.lang.python': 0.09; 'used).': 0.09; 'wrong,': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'thread': 0.11; '"exception': 0.16; 'guys,': 0.16; 'subject: \n ': 0.16; 'subject:most': 0.16; 'subject:raised': 0.16; 'win7': 0.16; 'wrote:': 0.17; 'thanks,': 0.18; 'skip:p 30': 0.20; 'import': 0.21; 'skip:_ 20': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; '2.6': 0.27; 'module.': 0.27; 'queue': 0.29; 'skip:q 20': 0.29; 'sleep': 0.29; 'workaround': 0.29; 'thursday,': 0.30; 'code': 0.31; 'skip:- 10': 0.32; 'could': 0.32; 'print': 0.32; 'says': 0.33; 'likely': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'sometimes': 0.35; 'there': 0.35; 'but': 0.36; 'subject: (': 0.36; 'correctly': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'google': 0.39; 'where': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; 'kind': 0.61; 'here': 0.65; 'race': 0.71; 'saw': 0.75; '2013': 0.84; 'misuse': 0.84; 'subject:during': 0.84; 'x64': 0.84; 'seriously,': 0.91; 'cause,': 0.93 X-Received: by 10.49.24.164 with SMTP id v4mr10805qef.6.1361500230833; Thu, 21 Feb 2013 18:30:30 -0800 (PST) Newsgroups: comp.lang.python Date: Thu, 21 Feb 2013 18:30:30 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=168.159.144.57; posting-account=EUV6tAoAAAA_IfJF_x-XYQxCI2bc4CDF References: <22cdc2c2-4851-4413-9c2c-b66f4b421b59@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 168.159.144.57 MIME-Version: 1.0 Subject: Re: Exception in thread QueueFeederThread (most likely raised during interpreter shutdown) From: Ziliang Chen To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361500240 news.xs4all.nl 6979 [2001:888:2000:d::a6]:54166 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39515 On Thursday, February 21, 2013 2:20:41 AM UTC+8, MRAB wrote: > On 2013-02-20 08:26, Ziliang Chen wrote: > Hi Guys, > I am using the mult= iprocessing module. The following code snippet occasionally throws the "Exc= eption in thread QueueFeederThread (most likely raised during interpreter s= hutdown)" exception. > > I searched google for the cause, someone says ther= e are some issues with the multiprocessing.Queue (need do some sleep at whe= re the queue is used). > > Could you please shed your light here, what is w= rong, how can I use the multiprocess correctly ? > > Thanks very much ! > >= The python version is 2.6 and on Win7 x64 OS. > > ------------------ > fro= m multiprocessing import Process,Queue > > def listTest(q): > print q.get()= > > def queueTest(): > q =3D Queue() > q.put([1,2,3,4,5,6]) > p =3D Proces= s(target=3DlistTest,args=3D(q,)) > p.start() > p.join() > > if __name__=3D= =3D'__main__': > queueTest() > > Exception in thread QueueFeederThread (mos= t likely raised during interpreter shutdown): > I think it may be a race co= ndition. When I tried it, sometimes it failed, sometimes it didn't. It seem= ed to be better behaved when I put a small sleep at the end to delay the ma= in process exiting. Thanks, MRAB! Yeah, I saw such kind of workaround after googling. But seriously, why is there a race condition here ? Is there any misuse of = queue here ?