I have a problem with matplotlib and multiprocessing. I start the first process, where I show the image and select the area, and close the shape. Then I start another process when I call the chart function, which is updated regularly. Up to this point, everything is working fine. Then, when I try to start another process using the SAME graph function, it freezes my entire computer, BUT the background processes work ... I have only one of these errors (this is not always the same thing):
error 1:
XIO: fatal error IO 25 (inappropriate ioctl for the device) on the X server ": 0.0" after 4438 requests (4438 known processed) with 30 events. XIO: fatal I / O error 11 (resource temporarily unavailable) on server X ": 0.0" after 4443 requests (4443 known processed) with 31 remaining events. [xcb] Unknown sequence number during queue processing [xcb] Most likely, this is a multithreaded client, and XInitThreads was not called [xcb] Aborting, sorry for that. python: .. /../src/xcb_io.c:274: poll_for_event: Statement `! xcb_xlib_threads_sequence_lost 'failed.
error 2:
X Failed request error: BadIDChoice (invalid resource identifier for this connection was selected) Main request operation code: 53 (X_CreatePixmap) Resource identifier in the failed request: 0x5600299 Sequential number of the failed request: 4793 Current serial number on the output stream: 4795 XIO: fatal error IO 25 (inappropriate ioctl for the device) on server X ": 0.0" after 4788 requests (4788 known processed) with 31 remaining events. XIO: fatal error IO 25 (inappropriate ioctl for the device) on the X server ": 0.0" after 4793 requests (4793 known processed) with 32 events.
The strange part is that I can completely start several processes that call the graph function without any problems, this is the connection with the first graph, which makes it unstable.
While trying to debug, I found that a simple fig=plt.figure() enough to collapse everything: in fact, any plt call ...
I read here and there that you can get matplotlib to use the agg backend and it helps with the multiprocessing process, but some widgets don't work with it, so I would like to avoid that.
I do not understand why using matplotlib in different processes can cause problems, so if someone could explain the reasons and / or help me with a workaround, it would be very nice.