Explorar o código

Update src/server/cache.py

Co-authored-by: Alexander Borzunov <hxrussia@gmail.com>
justheuristic %!s(int64=2) %!d(string=hai) anos
pai
achega
0f9d60badb
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      src/server/cache.py

+ 2 - 1
src/server/cache.py

@@ -100,7 +100,8 @@ class MemoryCache:
             )
         deadline = None if timeout is None else time.perf_counter() + timeout
         while self.current_size_bytes + allocated_size_bytes > self.max_size_bytes:
-            if not self._memory_freed_event.wait(deadline - time.perf_counter() if timeout is not None else None):
+            remaining_time = deadline - time.perf_counter() if timeout is not None else None
+            if not self._memory_freed_event.wait(remaining_time):
                 raise AllocationFailed(f"Could not allocate {allocated_size_bytes} bytes in {timeout} seconds")
             self._memory_freed_event.clear()