Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiprocessing: AttributeError: StdIn instance has no attribute 'close'

I get this error with multiprocessing when looping a simple range.

Process PoolWorker-37:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 249, in _bootstrap
    sys.stdin.close()
AttributeError: StdIn instance has no attribute 'close'

The code

pool = multiprocessing.Pool(processes=3)
pool.map(get_info, range(20000,20010), 1)
pool.close()
pool.join()

Update

the first issue was by eclipse altering the environment, but now I get this error

PicklingError: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed
like image 561
user642897 Avatar asked Jun 08 '12 11:06

user642897


2 Answers

This error is thrown if you are running in PyCharm console. I used the system console and all ran ok.

like image 89
Marcos Costa Avatar answered Oct 08 '22 19:10

Marcos Costa


In PyCharm 4.5 the solution for me was to remove "Show command line afterwards" checkbox in server Run/Debug configuration for python file (which is not even documented in PyCharm manual)

like image 32
Nikita Mendelbaum Avatar answered Oct 08 '22 18:10

Nikita Mendelbaum