Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Exception in thread QueueFeederThread (most likely raised duringinterpreter shutdown)

Reply
Thread Tools

Exception in thread QueueFeederThread (most likely raised duringinterpreter shutdown)

 
 
Ziliang Chen
Guest
Posts: n/a
 
      02-20-2013
Hi Guys,
I am using the multiprocessing module. The following code snippet occasionally throws the "Exception in thread QueueFeederThread (most likely raised during interpreter shutdown)" exception.

I searched google for the cause, someone says there are some issues with the multiprocessing.Queue (need do some sleep at where the queue is used).

Could you please shed your light here, what is wrong, how can I use the multiprocess correctly ?

Thanks very much !

The python version is 2.6 and on Win7 x64 OS.

------------------
from multiprocessing import Process,Queue

def listTest(q):
print q.get()

def queueTest():
q = Queue()
q.put([1,2,3,4,5,6])
p = Process(target=listTest,args=(q,))
p.start()
p.join()

if __name__=='__main__':
queueTest()

Exception in thread QueueFeederThread (most likely raised during interpreter shutdown):
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      02-20-2013
On 2013-02-20 08:26, Ziliang Chen wrote:
> Hi Guys,
> I am using the multiprocessing module. The following code snippet occasionally throws the "Exception in thread QueueFeederThread (most likely raised during interpreter shutdown)" exception.
>
> I searched google for the cause, someone says there are some issues with the multiprocessing.Queue (need do some sleep at where the queue is used).
>
> Could you please shed your light here, what is wrong, how can I use the multiprocess correctly ?
>
> Thanks very much !
>
> The python version is 2.6 and on Win7 x64 OS.
>
> ------------------
> from multiprocessing import Process,Queue
>
> def listTest(q):
> print q.get()
>
> def queueTest():
> q = Queue()
> q.put([1,2,3,4,5,6])
> p = Process(target=listTest,args=(q,))
> p.start()
> p.join()
>
> if __name__=='__main__':
> queueTest()
>
> Exception in thread QueueFeederThread (most likely raised during interpreter shutdown):
>

I think it may be a race condition. When I tried it, sometimes it
failed, sometimes it didn't.

It seemed to be better behaved when I put a small sleep at the end to
delay the main process exiting.

 
Reply With Quote
 
 
 
 
Ziliang Chen
Guest
Posts: n/a
 
      02-22-2013
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 multiprocessing module. The following code snippet occasionally throws the "Exception in thread QueueFeederThread (most likely raised during interpreter shutdown)" exception. > > I searched google for the cause, someone says there are some issues with the multiprocessing.Queue (need do some sleep at where the queue is used). > > Could you please shed your light here, what is wrong, how can I use the multiprocess correctly ? > > Thanks very much ! > >The python version is 2.6 and on Win7 x64 OS. > > ------------------ > from multiprocessing import Process,Queue > > def listTest(q): > print q.get()> > def queueTest(): > q = Queue() > q.put([1,2,3,4,5,6]) > p = Process(target=listTest,args=(q,)) > p.start() > p.join() > > if __name__=='__main__': > queueTest() > > Exception in thread QueueFeederThread (most likely raised during interpreter shutdown): > I think it may be a race condition. When I tried it, sometimes it failed, sometimes it didn't. It seemed to be better behaved when I put a small sleep at the end to delay the main 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 ?
 
Reply With Quote
 
Ziliang Chen
Guest
Posts: n/a
 
      02-22-2013
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 multiprocessing module. The following code snippet occasionally throws the "Exception in thread QueueFeederThread (most likely raised during interpreter shutdown)" exception. > > I searched google for the cause, someone says there are some issues with the multiprocessing.Queue (need do some sleep at where the queue is used). > > Could you please shed your light here, what is wrong, how can I use the multiprocess correctly ? > > Thanks very much ! > >The python version is 2.6 and on Win7 x64 OS. > > ------------------ > from multiprocessing import Process,Queue > > def listTest(q): > print q.get()> > def queueTest(): > q = Queue() > q.put([1,2,3,4,5,6]) > p = Process(target=listTest,args=(q,)) > p.start() > p.join() > > if __name__=='__main__': > queueTest() > > Exception in thread QueueFeederThread (most likely raised during interpreter shutdown): > I think it may be a race condition. When I tried it, sometimes it failed, sometimes it didn't. It seemed to be better behaved when I put a small sleep at the end to delay the main 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 ?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get a raised exception from other thread dcrespo Python 28 10-22-2005 03:10 PM
Exception raised in wrong thread? pegazik Python 1 09-20-2005 01:08 PM
exception raised for valid variable declaration? Carlos ASP .Net 1 02-17-2005 08:26 PM
Exception feature creep! (was: re-entering in the normal flow after an exception is raised) Lonnie Princehouse Python 8 10-02-2004 09:16 PM
capture exception raised by child thread. Joe Wong Python 1 05-14-2004 11:50 AM



Advertisments