Ver código fonte

Update src/server/cache.py

Co-authored-by: Alexander Borzunov <hxrussia@gmail.com>
justheuristic 2 anos atrás
pai
commit
0f9d60badb
1 arquivos alterados com 2 adições e 1 exclusões
  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
         deadline = None if timeout is None else time.perf_counter() + timeout
         while self.current_size_bytes + allocated_size_bytes > self.max_size_bytes:
         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")
                 raise AllocationFailed(f"Could not allocate {allocated_size_bytes} bytes in {timeout} seconds")
             self._memory_freed_event.clear()
             self._memory_freed_event.clear()