You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/12/07 10:14:09 UTC
[kibble-scanners] branch master updated: account for azure rate
limiting
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble-scanners.git
The following commit(s) were added to refs/heads/master by this push:
new ecc80ce account for azure rate limiting
ecc80ce is described below
commit ecc80ce1e3c4dee8afb0cc9a2cda434021686c65
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Dec 7 11:13:59 2017 +0100
account for azure rate limiting
---
src/plugins/scanners/ponymail-tone.py | 3 +++
src/plugins/utils/tone.py | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/src/plugins/scanners/ponymail-tone.py b/src/plugins/scanners/ponymail-tone.py
index a056f7f..c027a84 100644
--- a/src/plugins/scanners/ponymail-tone.py
+++ b/src/plugins/scanners/ponymail-tone.py
@@ -115,6 +115,9 @@ def scan(KibbleBit, source):
mood = plugins.utils.tone.watsonTone(KibbleBit, body)
elif 'azure' in KibbleBit.config:
mood = plugins.utils.tone.azureTone(KibbleBit, body)
+ if mood == False:
+ KibbleBit.pprint("Hit Azure rate limit, not trying further emails for now.")
+ break
eml['mood'] = mood
hm = [0,'unknown']
for m, s in mood.items():
diff --git a/src/plugins/utils/tone.py b/src/plugins/utils/tone.py
index 0ba3ca9..d9741e0 100644
--- a/src/plugins/utils/tone.py
+++ b/src/plugins/utils/tone.py
@@ -111,5 +111,11 @@ def azureTone(KibbleBit, body):
mood['neutral'] = max(0, 1 - (abs(val - 0.5) * 2)) # Between 25% and 75% use double the distance to middle.
else:
KibbleBit.pprint("Failed to analyze email body.")
+ # Depending on price tier, Azure will return a 429 if you go too fast.
+ # If we see a statusCode return, let's just stop for now.
+ # Later scans can pick up the slack.
+ if 'statusCode' in jsout:
+ KibbleBit.pprint("Possible rate limiting in place, stopping for now.")
+ return False
return mood
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
['"commits@kibble.apache.org" <co...@kibble.apache.org>'].