-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement graceful handling of WDQS rate-limiting #48
base: master
Are you sure you want to change the base?
Conversation
def refresh_labels(app_label, model, ids=None, queued_at=None): | ||
@celery.shared_task(bind=True, queue='wdqs') | ||
@utils.queries_wikidata | ||
def refresh_labels(self, app_label, model, ids=None, queued_at=None, rate_limiting_handler=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function refresh_labels
has 6 arguments (exceeds 4 allowed). Consider refactoring.
wdqs_rate_limiting = Signal(['retry_after']) | ||
|
||
|
||
def templated_wikidata_query(query_name: str, context: dict, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function templated_wikidata_query
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
rate_limiting_handler(False) | ||
|
||
|
||
def queries_wikidata(task_func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function queries_wikidata
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
@mock.patch('time.sleep') | ||
def testRetriesIfTooManyRequests(self, time_sleep, urlopen): | ||
retry_after = 10 | ||
urlopen.side_effect = HTTPError(url=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
@mock.patch('time.sleep') | ||
def testSuspendsConsuming(self, time_sleep, urlopen): | ||
retry_after = 10 | ||
urlopen.side_effect = HTTPError(url=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
6756e86
to
a75cadb
Compare
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
==========================================
+ Coverage 74.25% 75.69% +1.44%
==========================================
Files 50 51 +1
Lines 1503 1576 +73
==========================================
+ Hits 1116 1193 +77
+ Misses 387 383 -4
Continue to review full report at Codecov.
|
a75cadb
to
dfedd3e
Compare
Has tests, and seems to work locally too.
Closes #47.