def choose_judge_server(self):
        with transaction.atomic():
            servers = JudgeServer.objects.select_for_update().filter(workload__lt=100, lock=False, status=True).order_by("-workload")
            if servers.exists():
                server = servers.first()
                server.left_instance_number -= 1
                server.workload = 100 - int(float(server.left_instance_number) / server.max_instance_number * 100)
                server.save()
                return server
dataset/ETHPy150Open QingdaoU/OnlineJudge/judge_dispatcher/tasks.py/JudgeDispatcher.choose_judge_server/original