When writing a program using multiprocessing
and classes I sometimes stumble upon the exception
TypeError: cannot serialize '_io.TextIOWrapper' object
(the object can be different).
I understand why this is so and there are specific examples on how to fix specific cases.
Is there a straightforward way to tell which variable is causing the issue? This is not (at least for me) visible in the stack
Traceback (most recent call last):
File "C:/Users/yop/dev/checkssllabs/checkssllabs.py", line 62, in <module>
pool.map(s.analyse, sites)
File "C:\Python34\lib\multiprocessing\pool.py", line 260, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Python34\lib\multiprocessing\pool.py", line 599, in get
raise self._value
File "C:\Python34\lib\multiprocessing\pool.py", line 383, in _handle_tasks
put(task)
File "C:\Python34\lib\multiprocessing\connection.py", line 206, in send
self._send_bytes(ForkingPickler.dumps(obj))
File "C:\Python34\lib\multiprocessing\reduction.py", line 50, in dumps
cls(buf, protocol).dump(obj)
TypeError: cannot serialize '_io.TextIOWrapper' object
I will not be useful to post the (small) wall of code which generated this because I am looking for a generic way to hunt down these variables. Is the only way to analyze all of the imported modules and your own code, asking for every variable the question "is it serializable"?
To be totally frank I found, by miracle, the variable which was causing my specific problem but a generic approach would be very useful