Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:25:20+00:00 2026-06-05T13:25:20+00:00

I have a two files in python, proc1.py and proc2.py, Both are implementation of

  • 0

I have a two files in python, proc1.py and proc2.py, Both are implementation of a one-producer, multiple consumer scenario. proc1 in its main creates child processes. In each child process it calls proc2. proc2 in its code also creates child processes. proc2.py works correctly when executed from command line. But when called from proc1, i get the error

Traceback (most recent call last):
  File "./proc2.py", line 20, in proc2WorkerFunc
    elem = q.get(block = False)
  File "/usr/lib64/python2.6/multiprocessing/queues.py", line 103, in get
    if not self._poll(block and (deadline-time.time()) or 0.0):
IOError: [Errno 9] Bad file descriptor

I have tried searching online but so far have not got any clue. Any ideas on what i am doing wrong?
Proc1.py is

def workerFunc(q):                                                                   
  while True:                                                                        
    try:
      elem = q.get(block = False)                                                    
      print elem
      subprocess.call(["./proc2.py"])                                                
      time.sleep(0.5)
    except Queue.Empty:
      print "Queue is empty"                                                         
      return                                                                         
    except:
      print "Exception happened"
      tb = traceback.format_exc()                                                    
      print tb                                                                       
      return                                                                         




if __name__ == '__main__':
  q = multiprocessing.Queue()                                                        
  for i  in range(1):                                                                
    q.put('Hello')                                                                   

  num_workers = 1                                                                    
  workers = []
  for i in range(num_workers):
    qWorker = multiprocessing.Process(target=workerFunc, args=(q,))                  
    qWorker.start()
    workers.append(qWorker)                                                          

  for worker in workers:                                                             
    worker.join()
  print "proc 1 has finished"

proc2.py:

def proc2WorkerFunc(q):
  while True:
    try:
      print q.qsize()
      elem = q.get(block = False)
      print elem
      time.sleep(0.5)
    except Queue.Empty:
      print "Queue is empty"
      return
    except:
      print "Exception happened"
      tb = traceback.format_exc()
      print tb
      return




if __name__ == '__main__':
  proc2Q = multiprocessing.Queue()
  for i  in range(100):
    proc2Q.put('World')

  num_workers = 10
  workers = []
  for i in range(num_workers):
    qWorker = multiprocessing.Process(target=proc2WorkerFunc, args=(proc2Q,))
    qWorker.start()
    workers.append(qWorker)

  for worker in workers:
    worker.join()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:25:22+00:00Added an answer on June 5, 2026 at 1:25 pm

    Don’t know for sure, but since it seems you’re running Python 2.6 on a linux machine, and the code is working for me (using a windows machine and Python 2.7.3), you propably run into this bug.

    Which python version do you use exactly btw?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Python classes written in two different files. One is written in
I have two files, cars.txt and reservation.txt , both of the files have resID
I have two python files. From python file #1, I want to check to
I have two files, and I want to perform some line-wise operation across both
I've created two wave files using Audacity. Both have 44100hz sample rate, 32-bit float
I have two simple Python files: client.py and server.py . The client simply sends
I have two .csv files containing correlation matrices exported from R. One file contains
I have two files first of which is fizz #!/usr/bin/python import time print 'started'
Possible Duplicate: comparing contents of two files using python I have a file name
I'm using python 2.6 on linux. I have two text files first.txt has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.