def acquire(self):
if self.mutex_debug:
print("I2C mutex acquire")
acquired = False
while not acquired:
try:
self.DexterLockI2C_handle = open('/run/lock/DexterLockI2C', 'w')
# lock
fcntl.lockf(self.DexterLockI2C_handle, fcntl.LOCK_EX | fcntl.LOCK_NB)
acquired = True
except IOError: # already locked by a different process
time.sleep(0.001)
except Exception as e:
print(e)
if self.mutex_debug:
print("I2C mutex acquired {}".format(time.time()))
评论列表
文章目录