def _lock(self): if not fcntl or not self.ser: return fcntl.flock(self.ser.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) logging.debug('_lock')