Exception in thread QueueFeederThread (most likely raised duringinterpreter shutdown)

Z

Ziliang Chen

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):
 
M

MRAB

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.
 
Z

Ziliang Chen

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 ?
 
Z

Ziliang Chen

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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top