def remove_job(self, job):
    locks = list(self.all_by_job[job.id])
    n = len(locks)
    for lock in locks:
        if lock.write:
            self.write_locks.remove(lock)
            self.write_by_item[lock.locked_item].remove(lock)
        else:
            self.read_locks.remove(lock)
            self.read_by_item[lock.locked_item].remove(lock)
        self.all_by_job[job.id].remove(lock)
        self.all_by_item[lock.locked_item].remove(lock)
        self.call_receivers(lock, self.LOCK_REMOVE)
    return n
def remove_job(self, job):
    locks = list(self.all_by_job[job.id])
    n = len(locks)
    for lock in locks:
        if lock.write:
            self.write_locks.remove(lock)
            self.write_by_item[lock.locked_item].remove(lock)
        else:
            self.read_locks.remove(lock)
            self.read_by_item[lock.locked_item].remove(lock)
        self.all_by_job[job.id].remove(lock)
        self.all_by_item[lock.locked_item].remove(lock)
        self.call_receivers(lock, self.LOCK_REMOVE)
    return n