Commit 903e9233 authored by Ajil K's avatar Ajil K

added timeout and removed unwanted commented portions

parent e4bc86c3
...@@ -7,4 +7,4 @@ paho-mqtt==1.5.0 ...@@ -7,4 +7,4 @@ paho-mqtt==1.5.0
PyJWT==2.4.0 PyJWT==2.4.0
ping3==4.0.4 ping3==4.0.4
psutil==5.9.6 psutil==5.9.6
httpx~=0.28.1 httpx==0.24.1
\ No newline at end of file \ No newline at end of file
# import logging
# import os
# from logging.handlers import RotatingFileHandler
#
#
# logger_topic = None
# logging.trace = logging.DEBUG - 5
# logging.addLevelName(logging.DEBUG - 5, "TRACE")
#
# class EngineLoggerClass(logging.getLoggerClass()):
# def __init__(self, name):
# super().__init__(name)
#
# def trace(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.trace):
# self._log(logging.trace, msg, args, **kwargs)
#
# def info(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.INFO):
# self._log(logging.INFO, msg, args, **kwargs)
#
# def debug(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.DEBUG):
# self._log(logging.DEBUG, msg, args, **kwargs)
#
# def warning(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.WARNING):
# self._log(logging.WARNING, msg, args, **kwargs)
#
# def error(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.ERROR):
# self._log(logging.ERROR, msg, args, **kwargs, extra={"__logger_topic__": logger_topic})
#
# def critical(self, msg, *args, **kwargs):
# if self.isEnabledFor(logging.CRITICAL):
# self._log(logging.CRITICAL, msg, args, **kwargs)
#
# def get_logger():
# """
# Creates a rotating log
# """
# logging.setLoggerClass(EngineLoggerClass)
# __logger__ = logging.getLogger('')
#
# # setting the logger level
# __logger__.setLevel("INFO")
#
# # creating the format for the log
# log_formatter = "%(asctime)s-%(levelname)-s-[%(funcName)5s():%(lineno)s]-%(message)s"
# time_format = "%Y-%m-%d %H:%M:%S"
#
# # getting the path for the logger
# file_path = "logs"
#
# # setting the format
# formatter = logging.Formatter(log_formatter, time_format)
#
# # creating the folder if not exist
# if not os.path.exists(file_path):
# os.makedirs(file_path)
#
# # joining the path
# log_file = os.path.join(f"{file_path}/redundancy.log")
#
# # creating rotating file handler with max byte as 1
# temp_handler = RotatingFileHandler(log_file,
# maxBytes=1000000000,
# backupCount=5)
#
# # setting the formatter
# temp_handler.setFormatter(formatter)
#
# # setting the handler
# __logger__.addHandler(temp_handler)
#
# return __logger__
#
#
# logger = get_logger()
import json import json
import logging import logging
import os import os
......
...@@ -18,7 +18,7 @@ def post_data(json_data, logger, endpoint="receive_data"): ...@@ -18,7 +18,7 @@ def post_data(json_data, logger, endpoint="receive_data"):
logger.trace("Entered in post_data") logger.trace("Entered in post_data")
monitoring_endpoint = f"http://{app_config.host_ip}:{app_config.port_no}/{endpoint}" monitoring_endpoint = f"http://{app_config.host_ip}:{app_config.port_no}/{endpoint}"
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}
response = httpx.post(monitoring_endpoint, data=json.dumps(json_data), headers=headers) response = httpx.post(monitoring_endpoint, data=json.dumps(json_data), headers=headers, timeout=60)
if response.status_code == 200: if response.status_code == 200:
response_data = response.content.decode() response_data = response.content.decode()
logger.trace(f"response_data: {response_data}") logger.trace(f"response_data: {response_data}")
......
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