mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Merge pull request #1496 from GSA/notify-api-1495
introduce gaps in message sends
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from celery.signals import task_postrun
|
from celery.signals import task_postrun
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
@@ -75,8 +76,18 @@ def process_job(job_id, sender_id=None):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# notify-api-1495 we are going to sleep periodically to give other
|
||||||
|
# jobs running at the same time a chance to get some of their messages
|
||||||
|
# sent. Sleep for 1 second after every 3 sends, which gives us throughput
|
||||||
|
# of about 3600*3 per hour and would keep the queue clear assuming only one sender.
|
||||||
|
# It will also hopefully eliminate throttling when we send messages which we are
|
||||||
|
# currently seeing.
|
||||||
|
count = 0
|
||||||
for row in recipient_csv.get_rows():
|
for row in recipient_csv.get_rows():
|
||||||
process_row(row, template, job, service, sender_id=sender_id)
|
process_row(row, template, job, service, sender_id=sender_id)
|
||||||
|
count = count + 1
|
||||||
|
if count % 3 == 0:
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
# End point/Exit point for message send flow.
|
# End point/Exit point for message send flow.
|
||||||
job_complete(job, start=start)
|
job_complete(job, start=start)
|
||||||
|
|||||||
Reference in New Issue
Block a user