Unable to use servo function from inside a multiprocessing pool
I've been trying to use this reliefMCWFS.py for utilizing the servo function. However, I'm getting following error:
$ python reliefMCWFS.py -t 1
Starting the 1.0 second relief servos...
/usr/lib/python3/dist-packages/epics/ca.py:1507: UserWarning: ca.get('C1:SUS-MC1_PIT_COMM') timed out after 1.00 seconds.
warnings.warn(msg % (name(chid), timeout))
/usr/lib/python3/dist-packages/epics/ca.py:1507: UserWarning: ca.get('C1:SUS-MC1_YAW_COMM') timed out after 1.00 seconds.
warnings.warn(msg % (name(chid), timeout))
/usr/lib/python3/dist-packages/epics/ca.py:1507: UserWarning: ca.get('C1:SUS-MC2_YAW_COMM') timed out after 1.00 seconds.
warnings.warn(msg % (name(chid), timeout))
/usr/lib/python3/dist-packages/epics/ca.py:1507: UserWarning: ca.get('C1:SUS-MC3_PIT_COMM') timed out after 1.00 seconds.
warnings.warn(msg % (name(chid), timeout))
/usr/lib/python3/dist-packages/epics/ca.py:1507: UserWarning: ca.get('C1:SUS-MC2_PIT_COMM') timed out after 1.00 seconds.
warnings.warn(msg % (name(chid), timeout))
/usr/lib/python3/dist-packages/epics/ca.py:1507: UserWarning: ca.get('C1:SUS-MC3_YAW_COMM') timed out after 1.00 seconds.
warnings.warn(msg % (name(chid), timeout))
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "reliefMCWFS.py", line 22, in servo
while ((not ser.step())
File "/usr/lib/python3/dist-packages/cdsutils/servo.py", line 119, in step
ctrl1_current = self._ezca.read(self._chan1, use_monitor=False)
File "/usr/lib/python3/dist-packages/ezca/ezca.py", line 297, in read
raise EzcaConnectError("Could not get value from channel: %s" % (pv.pvname))
ezca.errors.EzcaConnectError: Could not get value from channel: C1:SUS-MC1_YAW_COMM
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "reliefMCWFS.py", line 51, in reliefMCWFS
p.map(servo, argList)
File "/usr/lib/python3.7/multiprocessing/pool.py", line 268, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/usr/lib/python3.7/multiprocessing/pool.py", line 657, in get
raise self._value
ezca.errors.EzcaConnectError: Could not get value from channel: C1:SUS-MC1_YAW_COMM
Do you want to reset IMC optics to initial alignments? (y/n)n
Doing nothing
The above error does not happen when the servo function is directly called instead of through a multiprocessing pool. Can someone help me resolve this? I need these servos to run simultaneously and graciosuly exit in case lock is lost in a cavity.