def _add(self, lock):
    assert (lock.job.id is not None)
    if lock.write:
        self.write_locks.append(lock)
        self.write_by_item[lock.locked_item].append(lock)
    else:
        self.read_locks.append(lock)
        self.read_by_item[lock.locked_item].append(lock)
    self.all_by_job[lock.job.id].append(lock)
    self.all_by_item[lock.locked_item].append(lock)
    self.call_receivers(lock, self.LOCK_ADD)
def _add(self, lock):
    assert (lock.job.id is not None)
    if lock.write:
        self.write_locks.append(lock)
        self.write_by_item[lock.locked_item].append(lock)
    else:
        self.read_locks.append(lock)
        self.read_by_item[lock.locked_item].append(lock)
    self.all_by_job[lock.job.id].append(lock)
    self.all_by_item[lock.locked_item].append(lock)
    self.call_receivers(lock, self.LOCK_ADD)