Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #64

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ redis
tc-core-analyzer-lib==1.1.0
tc-neo4j-lib==1.0.0
pybars3
backoff==2.2.1
10 changes: 9 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import logging
from typing import Any

import backoff
from discord_utils import analyzer_recompute, analyzer_run_once, publish_on_success
from pika.exceptions import AMQPConnectionError, ConnectionClosedByBroker
from redis import Redis
from rq import Queue as RQ_Queue
from tc_messageBroker.message_broker import RabbitMQ
Expand All @@ -19,6 +21,12 @@
from utils.sentryio_service import set_up_sentryio


@backoff.on_exception(
wait_gen=backoff.expo,
exception=(ConnectionClosedByBroker, ConnectionError, AMQPConnectionError),
# waiting for 3 hours
max_time=60 * 60 * 3,
)
def analyzer():
rabbit_mq_creds = get_rabbit_mq_credentials()
sentry_creds = get_sentryio_service_creds()
Expand Down Expand Up @@ -56,7 +64,7 @@ def analyzer():
rabbit_mq.on_event(Event.DISCORD_ANALYZER.RUN_ONCE, analyzer_run_once)

if rabbit_mq.channel is None:
logging.info("Error: was not connected to RabbitMQ broker!")
raise ConnectionError("Couldn't connect to rmq server!")
else:
logging.info("Started Consuming!")
rabbit_mq.channel.start_consuming()
Expand Down
Loading