Check if ACS is up
@sadeh and me were looking how to find out if ACS is up or down.
I thought ACSCorba.getManager()
gives the right answer, but this did not work, since the answer to getManager
is cached in ACSCorba.MGR_REF
.
So when stopping / starting ACS, getManager() would always return a manager instance, even when ACS is down (if it ever was up). So there are different ways out here:
Either invalidate the cache, e.g. like this:
from Acspy.Util import ACSCorba
def is_acs_up():
ACSCorba.MGR_REF = None
return ACSCorba.getManager() is not None
Or try to exercise some manager interface, which should fail, when ACS is down, e.g. using get_client_info(...)
:
from Acspy.Util.ACSCorba import getManager
from maci import HANDLE_MANAGER_MASK
def is_acs_up():
manager = getManager()
try:
manager.get_client_info(HANDLE_MANAGER_MASK, [], "*")
return True
except Exception:
return False
Edited by Dominik Neise