From eba892ea9d4b466c095b4c149c365ee31fd8db59 Mon Sep 17 00:00:00 2001 From: DragonAura <32223554+DragonAura@users.noreply.github.com> Date: Thu, 9 May 2024 00:22:45 +0800 Subject: [PATCH 1/2] fix: remove python retry --- CAPI/python/PyAPI/Communication.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/CAPI/python/PyAPI/Communication.py b/CAPI/python/PyAPI/Communication.py index 9733011f..8f49aa39 100644 --- a/CAPI/python/PyAPI/Communication.py +++ b/CAPI/python/PyAPI/Communication.py @@ -235,18 +235,14 @@ def BuildShip( return buildResult.act_success def TryConnection(self, playerID: int, teamID: int) -> bool: - maxRetryNum: int = 10 - for _ in range(maxRetryNum): - try: - time.sleep(1) - tryResult: Message2Clients.BoolRes = self.__THUAI7Stub.TryConnection( - THUAI72Proto.THUAI72ProtobufIDMsg(playerID, teamID) - ) - except grpc.RpcError: - continue - else: - return tryResult.act_success - return False + try: + tryResult: Message2Clients.BoolRes = self.__THUAI7Stub.TryConnection( + THUAI72Proto.THUAI72ProtobufIDMsg(playerID, teamID) + ) + except grpc.RpcError: + return False + else: + return tryResult.act_success def GetMessage2Client(self) -> Message2Clients.MessageToClient: with self.__cvMessage: From 30b3530963ad2e11f2190a4d72e07232be3c6c56 Mon Sep 17 00:00:00 2001 From: DragonAura <32223554+DragonAura@users.noreply.github.com> Date: Thu, 9 May 2024 00:23:33 +0800 Subject: [PATCH 2/2] fix: remove cpp retry --- CAPI/cpp/API/src/Communication.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/CAPI/cpp/API/src/Communication.cpp b/CAPI/cpp/API/src/Communication.cpp index 45100a8e..6c86b7eb 100755 --- a/CAPI/cpp/API/src/Communication.cpp +++ b/CAPI/cpp/API/src/Communication.cpp @@ -227,18 +227,14 @@ bool Communication::Recycle(int32_t playerID, int32_t teamID) bool Communication::TryConnection(int32_t playerID, int32_t teamID) { - constexpr int maxRetryNum = 10; + protobuf::BoolRes reply; + ClientContext context; auto request = THUAI72Proto::THUAI72ProtobufIDMsg(playerID, teamID); - for (int retryNum = 0; retryNum < maxRetryNum; retryNum++) - { - protobuf::BoolRes reply; - ClientContext context; - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - auto status = THUAI7Stub->TryConnection(&context, request, &reply); - if (status.ok()) - return true; - } - return false; + auto status = THUAI7Stub->TryConnection(&context, request, &reply); + if (status.ok()) + return true; + else + return false; } void Communication::AddPlayer(int32_t playerID, int32_t teamID, THUAI7::ShipType ShipType)