0

I'm using a Linux 18.04.2 LTS 64 bit machine.

The function that is parallelized does plotting, and using savefig module saves the plot in pdf format.

Currently, I'm running 100 iterations. Oddly, either 0th, 1st, 2nd or the 3rd iteration generates a proper pdf file, while all other generated pdf files are of size 0 bytes.

At every iteration a message similar to this is produced:

Gdk-Message: 14:41:40.404: python2.7: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

At the completion of the task, the process freezes, and I have to reboot my system. When I comment out the plotting part, the code does the job, but incorporating the plotting part results in the above error message.

These are the lines of code that do the multiprocessing. When the function is called without these lines, a proper pdf file is generated (that is when the code is run sequentially)

from multiprocessing import Pool
import time
if __name__ == "__main__":
    # Step 1: Init multiprocessing.Pool()
    pool = Pool()
    results = []
    # Step 2: `pool.apply` the `mcoverpc()`
    print('START')
    start_time = int(round(time.time()))
    data = list(range(100))
    result_objects = [pool.apply_async(function, args=(num,arg1,arg2,arg3)) for num in data]
    # Step 3: Don't forget to close
    result_num = [r.get()[0] for r in result_objects]
    result_pc = [r.get()[1] for r in result_objects]
    result_fit_details = [r.get()[2] for r in result_objects]
    result_redchi = [r.get()[3] for r in result_objects] 
    pool.close()
    pool.terminate()
    print('END', int(round(time.time()))-start_time)
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Sameeresque
  • 2,464
  • 1
  • 9
  • 22

1 Answers1

0

I got to resolve this issue by simply changing the matplotlib backend to non-interactive type. Particularly, I've used PDF as the backend.

Sameeresque
  • 2,464
  • 1
  • 9
  • 22