Update the flask-socketio config to play more nicely:

* Reverts run commands to what they previously were
* Addresses some outstanding linting/formatting
* Accounts for proper config initialization (CORS, Redis)
* Updates dependencies and pulls in latest changes from main

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2025-04-16 17:43:10 -04:00
parent 71e8f20b04
commit 419d6cee69
8 changed files with 29 additions and 19 deletions

View File

@@ -32,13 +32,6 @@ from notifications_utils.clients.encryption.encryption_client import Encryption
from notifications_utils.clients.redis.redis_client import RedisClient
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
socketio = SocketIO(
cors_allowed_origins="*",
message_queue="redis://localhost:6379",
logger=True,
engineio_logger=True
)
class NotifyCelery(Celery):
def init_app(self, app):
@@ -102,6 +95,14 @@ zendesk_client = ZendeskClient()
redis_store = RedisClient()
document_download_client = DocumentDownloadClient()
socketio = SocketIO(
cors_allowed_origins=[
config.Config.ADMIN_BASE_URL,
],
message_queue=config.Config.REDIS_URL,
logger=True,
engineio_logger=True,
)
notification_provider_clients = NotificationProviderClients()
@@ -122,6 +123,7 @@ def create_app(application):
socketio.init_app(application)
from app.socket_handlers import register_socket_handlers
register_socket_handlers(socketio)
request_helper.init_app(application)
db.init_app(application)

View File

@@ -179,6 +179,7 @@ class Config(object):
S3_RESOURCE = session.resource("s3", config=AWS_CLIENT_CONFIG)
CELERY = {
"broker_connection_retry_on_startup": True,
"worker_max_tasks_per_child": 500,
"task_ignore_result": True,
"result_persistent": False,

View File

@@ -898,10 +898,15 @@ def dao_update_delivery_receipts(receipts, delivered):
updated {len(receipts)} notification in {elapsed_time} ms"
)
current_app.logger.info("✅✅✅✅ Reached delivery receipt processing")
job_ids = db.session.execute(
select(Notification.job_id)
.where(Notification.message_id.in_(id_to_carrier.keys()))
).scalars().all()
job_ids = (
db.session.execute(
select(Notification.job_id).where(
Notification.message_id.in_(id_to_carrier.keys())
)
)
.scalars()
.all()
)
for job_id in set(job_ids):
job = dao_get_job_by_id(job_id)

View File

@@ -144,5 +144,5 @@ def emit_job_update_summary(job):
"job_status": job.job_status,
"notification_count": job.notification_count,
},
room=f"job-{job.id}"
room=f"job-{job.id}",
)