Small changes (to work with preset)

This commit is contained in:
Kiryl
2022-07-27 20:20:28 +03:00
parent 84b692d39b
commit 617d4fcaef
2 changed files with 29 additions and 29 deletions

View File

@@ -77,7 +77,6 @@ def callback(ch, method, properties, body, logger, libre_locker):
thread.start()
logging.log(logging.INFO, f"Active threads: {active_count()}.")
# print(f"Active threads: {active_count()}.")
except Exception as exc:
if hasattr(exc, "message"):
logger.error(f"{sys.exc_info()[0]}: {exc.message}")
@@ -90,15 +89,18 @@ def callback(ch, method, properties, body, logger, libre_locker):
def server_run():
logger = configure_file_logger("consumer")
channel = None
try:
folder_path = os.path.dirname(os.path.abspath(__file__))
config_path = Path(os.path.join(folder_path, "config/queue_config.json"))
config_path = Path(os.path.join(
folder_path, "config/queue_config.json"))
with open(config_path, "r") as f:
conf_param = json.load(f)
host = conf_param.get("host") or pika.ConnectionParameters().DEFAULT_HOST
port = conf_param.get("port") or pika.ConnectionParameters().DEFAULT_PORT
channel = None
host = conf_param.get(
"host") or pika.ConnectionParameters().DEFAULT_HOST
port = conf_param.get(
"port") or pika.ConnectionParameters().DEFAULT_PORT
credentials = pika.PlainCredentials(
username=conf_param["username"], password=conf_param["password"])
parameters = pika.ConnectionParameters(
@@ -113,7 +115,6 @@ def server_run():
logger.log(logging.ERROR,
f"Queue {conf_param['queue']} is not declared.")
raise exc
locker = Event()
locker.set()
channel.basic_consume(queue=conf_param["queue"],