def close(self): try: # port... if self._ser: self._ser.close() self._ser = None finally: # lock... Lock.release(self.__lock_name)
def __get_output(self, mask): if self.__device is None: return None Lock.acquire(IO.__lock_name(IO.__LOCK), IO.__LOCK_TIMEOUT) try: byte = self.__device.state.byte return bool(byte & mask) finally: Lock.release(IO.__lock_name(IO.__LOCK))
def __set_output(self, mask, level): if self.__device is None: return Lock.acquire(IO.__lock_name(IO.__LOCK), IO.__LOCK_TIMEOUT) try: byte = self.__device.state.byte if level: byte |= mask else: byte &= ~mask self.__device.write(byte) self.__device.state = byte finally: Lock.release(IO.__lock_name(IO.__LOCK))
def end_tx(self): Lock.release(self.__lock_name(Modem.__LOCK_PWR))
def release_lock(cls): Lock.release(cls.__lock_name())
def release_lock(self): Lock.release(self.__class__.__name__)
def release_lock(cls): Lock.release(cls.__name__)
def release_lock(self): Lock.release(self.lock_name)
def end_tx(self): Lock.release(self.__lock_name(GE910.__LOCK_TX))
def end_tx(cls): Lock.release(cls.__name__)
def end_tx(self): Lock.release(self.__class__.__name__)
print("pid: %s" % str(pid)) print("-") # -------------------------------------------------------------------------------------------------------------------- Lock.acquire(name, 4.0) print("locked...") try: exists = Lock.exists(name) print("exists: %s" % exists) pid = Lock.pid(name) print("pid: %s" % str(pid)) print("-") while True: time.sleep(1) except KeyboardInterrupt: pass finally: Lock.release(name) print() print("unlocked")