Commit c8962cbb authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added while loop.

parent 5e2a2eac
......@@ -7,6 +7,7 @@ from redis_semaphore import Semaphore
from redis.exceptions import ConnectionError as RedisConnectionError
import functools
from psutil import virtual_memory
import random
from ..misc.logging import GMS_logger
from ..options.config import GMS_config as CFG
......@@ -172,11 +173,11 @@ class MemoryReserver(Semaphore):
def acquire(self, timeout=0, target=None):
if not self.disabled:
token = self.client.getset(self.acquisition_key, self.exists_val)
def check_acquisition_key():
return self.client.getset(self.acquisition_key, self.exists_val)
if token:
while check_acquisition_key() is not None:
time.sleep(random.uniform(1, 5))
self.client.expire(self.acquisition_key, 10)
......@@ -198,7 +199,7 @@ class MemoryReserver(Semaphore):
% (self.usable_memory_gb, self.mem2lock_gb))
self._waiting = True
time.sleep(random.uniform(1, 2))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment