From eb512b62c55ec70136564182bf59b9eea3d847a3 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Thu, 22 Sep 2022 19:12:44 +0800 Subject: [PATCH] fix(mgb/imperative): fix the future_error caused by repeat get calls at the same std::future GitOrigin-RevId: f1a835fa5cb77551937f093bdeea0829f57d8fee --- imperative/src/impl/persistent_cache.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/imperative/src/impl/persistent_cache.cpp b/imperative/src/impl/persistent_cache.cpp index 0c180af2d..63b4ab4ca 100644 --- a/imperative/src/impl/persistent_cache.cpp +++ b/imperative/src/impl/persistent_cache.cpp @@ -68,18 +68,12 @@ public: encode(category + '@' + key_str, redis_key_str, 24); auto result = m_client.get(m_prefix + redis_key_str); sync(); - decltype(result.get()) content; - int try_number = 3; - for (int i = 0; i < try_number; i++) { - content = result.get(); - if (!content.is_null()) { - break; - } - } + auto content = result.get(); if (content.is_null()) { return None; } std::string decode_content; + mgb_assert(content.is_string()); decode(content.as_string(), decode_content); m_local->put(category, key, {decode_content.data(), decode_content.length()}); return m_local->get(category, key); -- GitLab