Exception in thread QueueFeederThread (most likely raised duringinterpreter shutdown)

Discussion in 'Python' started by Ziliang Chen, Feb 20, 2013.

  1. Ziliang Chen

    Ziliang Chen Guest

    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):
     
    Ziliang Chen, Feb 20, 2013
    #1
    1. Advertising

  2. Ziliang Chen

    MRAB Guest

    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.
     
    MRAB, Feb 20, 2013
    #2
    1. Advertising

  3. Ziliang Chen

    Ziliang Chen Guest

    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 ?
     
    Ziliang Chen, Feb 22, 2013
    #3
  4. Ziliang Chen

    Ziliang Chen Guest

    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 ?
     
    Ziliang Chen, Feb 22, 2013
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    359
  2. Joe Wong
    Replies:
    1
    Views:
    472
    Ype Kingma
    May 14, 2004
  3. Ken Guest
    Replies:
    2
    Views:
    297
    Ken Guest
    Jan 6, 2006
  4. Sune
    Replies:
    10
    Views:
    595
    Martin Ambuhl
    Oct 7, 2005
  5. Adam Cohen
    Replies:
    1
    Views:
    138
    Greg Willits
    Jun 14, 2010
Loading...

Share This Page