Skip to content

Commit

Permalink
fixed redis connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
antbaez9 committed Jul 11, 2024
1 parent 50d35dd commit 962471a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions distributask/distributask.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,11 @@ def get_redis_connection(self, force_new: bool = False) -> Redis:
if self.redis_client is not None and not force_new:
return self.redis_client
else:
self.pool = ConnectionPool(max_connections=1)
self.redis_client = Redis(
connection_pool=self.pool,
host=self.settings["REDIS_HOST"],
port=self.settings["REDIS_PORT"],
password=self.settings["REDIS_PASSWORD"],
)
self.pool = ConnectionPool(host=self.settings["REDIS_HOST"],
port=self.settings["REDIS_PORT"],
password=self.settings["REDIS_PASSWORD"],
max_connections=1)
self.redis_client = Redis(connection_pool=self.pool)
atexit.register(self.pool.disconnect)

return self.redis_client
Expand Down Expand Up @@ -662,11 +660,14 @@ def get_node_log(self, node: Dict, wait_time: int = 2):
response = requests.request(
"PUT", url, headers=headers, json=payload, timeout=5
)
log_url = response.json()["result_url"]
time.sleep(wait_time)
log_response = requests.get(log_url, timeout=5)

return log_response
if response.status_code == 200:
log_url = response.json()["result_url"]
time.sleep(wait_time)
log_response = requests.get(log_url, timeout=5)
return log_response
else:
return None

def terminate_nodes(self, nodes: List[Dict]) -> None:
"""
Expand Down

0 comments on commit 962471a

Please sign in to comment.