CFN-softbio/SciAnalysis

XIO error when using parallelization.

Closed this issue · 1 comments

When using the new "run_parallel" method, the script will randomly hang and lockup the desktop environment. The errors are like:

Running tile_img for tile
Running tile_svg for tile
Running average_image for tile
Processing 100 infiles...
Queueing thumbnails for tile_x001_y004
Queueing thumbnails for tile_x001_y003
Queueing thumbnails for tile_x001_y001
Queueing thumbnails for tile_x001_y002
Queueing thumbnails for tile_x001_y005
XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":0"
after 1202 requests (1202 known processed) with 90 events remaining.
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
after 1202 requests (1202 known processed) with 90 events remaining.
XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":0"
after 1210 requests (1210 known processed) with 112 events remaining.
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
after 1202 requests (1202 known processed) with 90 events remaining.
XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":0"
after 1202 requests (1202 known processed) with 90 events remaining.

This is most likely due to matplotlib trying to plot things in a pseudo-headless context. (I.e. it's trying to launch a GUI of some kind but finds itself in one of the subprocess environments launched by joblib.)

E.g. these similar issues:

https://stackoverflow.com/questions/45993879/matplot-lib-fatal-io-error-25-inappropriate-ioctl-for-device-on-x-server-loc

https://stackoverflow.com/questions/28903969/python-multiprocessingsavefig-leads-to-error-or-system-lockup

The fix is to switch to the 'Agg' environment in mpl:

import matplotlib as mpl
mpl.use('Agg')
import pylab as plt
print(plt.get_backend())