def acquireDiskResource(ngamsCfgObj,
slotId):
"""
Acquire access right to a disk resource.
ngamsCfgObj: NG/AMS Configuration Object (ngamsConfig).
slotId: Slot ID referring to the disk resource (string).
Returns: Void.
"""
T = TRACE()
storageSet = ngamsCfgObj.getStorageSetFromSlotId(slotId)
if (not storageSet.getMutex()): return
global _diskMutexSems
if (not _diskMutexSems.has_key(slotId)):
_diskMutexSems[slotId] = threading.Semaphore(1)
code = string.split(str(abs(random.gauss(10000000,10000000))), ".")[0]
logger.debug("Requesting access to disk resource with Slot ID: %s (Code: %s)",
slotId, str(code))
_diskMutexSems[slotId].acquire()
logger.debug("Access granted")
评论列表
文章目录