updated app.py

This commit is contained in:
2020-05-08 22:05:49 +02:00
parent 77e915c63e
commit 7ce88f1a74
3 changed files with 20 additions and 67 deletions

View File

@@ -2,6 +2,7 @@
import os
import logging
import requests
import requests.exceptions
from redis_super_storage import RedisSuperStorage
@@ -16,7 +17,7 @@ class ProducerCommunicator:
for key, ip in self._redis_store.get_producer_list().items():
try:
response = requests.post(
response = self._session.post(
f"http://{ip}/ip",
json={'uuid': os.environ['LOCAL_UUID'], 'ip': newip},
timeout=5
@@ -35,7 +36,7 @@ class ConsumerCommunicator:
def targeted_snyc(self, ip: str):
try:
# request synchronization
response = requests.post(f"http://{ip}/sync", json={'uuid': os.environ['LOCAL_UUID']}, timeout=5)
response = self._session.post(f"http://{ip}/sync", json={'uuid': os.environ['LOCAL_UUID']}, timeout=5)
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
logging.error(f"Error while syncing to {ip}: {str(e)}")