mirror of
https://github.com/sartography/uva-covid19-testing-communicator.git
synced 2025-02-23 12:28:26 +00:00
trottle text messages as well.
This commit is contained in:
parent
a84a14f3e5
commit
dd7b40f5a9
@ -116,6 +116,7 @@ def _notify_by_text(file_name=None, retry=False):
|
||||
|
||||
# Do not limit texts, as errors pile up we end up sending less and less, till none go out.
|
||||
# sample_query = sample_query.limit(150) # Only send out 150 texts at a time.
|
||||
count = 0
|
||||
samples = sample_query.all()
|
||||
for sample in samples:
|
||||
last_failure = sample.last_failure_by_type(TEXT_TYPE)
|
||||
@ -128,5 +129,8 @@ def _notify_by_text(file_name=None, retry=False):
|
||||
except Exception as e:
|
||||
db.session.add(Notification(type=TEXT_TYPE, sample=sample, successful=False,
|
||||
error_message=str(e)))
|
||||
count += 1
|
||||
db.session.commit()
|
||||
sleep(0.5)
|
||||
if count % 100 == 0:
|
||||
sleep(300) # Sleep for 5 minutes after every 100 records to avoid throttling errors.
|
||||
|
Loading…
x
Reference in New Issue
Block a user