0

The code runs smoothly for quite some time, then suddenly it gives OSError: [Errno 12] Cannot allocate memory

def initialize(site):
    global pool

    if site == 'OT':
        for jobId in JobIdsOT:
            argumentList = [jobId, site]
            pool.map(assignTask, [argumentList])            

    elif site == 'LI':                
        for jobId in JobIdsLI:
            argumentList = [jobId, site]
            pool.map(assignTask, [argumentList]) 

StackTrace:

Traceback (most recent call last):
  File "LogDumper.py", line 301, in <module>
    main()
  File "LogDumper.py", line 58, in main
    initialize('OT')
  File "LogDumper.py", line 78, in initialize
    pool.map(assignTask, [argumentList])            
  File "/usr/lib64/python2.6/multiprocessing/pool.py", line 148, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/lib64/python2.6/multiprocessing/pool.py", line 422, in get
    raise self._value
OSError: [Errno 12] Cannot allocate memory

I referred this question Python cannot allocate memory using multiprocessing.pool . But I am not sure about the solution.

How can I resolve the aforementioned issue?

Community
  • 1
  • 1
John Rambo
  • 906
  • 1
  • 17
  • 37

1 Answers1

0

Change to.

for jobId in JobIdsOT:
        argumentList.append( (jobId, site) )
 pool.map(assignTask, argumentList)  

pool.map(... expect only one iterable and has to be called only once for all job's.

stovfl
  • 14,998
  • 7
  • 24
  • 51