Fix useless waiting time before creating items when uploading to Wikibase. (#4227)

Checks that there is at least one item to fetch before attempting to fetch
anything.

Closes #4226.
This commit is contained in:
Antonin Delpeuch 2021-10-22 08:52:28 +02:00 committed by GitHub
parent 235b5957e2
commit 6372f2d382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,7 +223,7 @@ public class EditBatchProcessor {
int backoff = 2;
int sleepTime = 5000;
// TODO: remove currentDocs.isEmpty() once https://github.com/Wikidata/Wikidata-Toolkit/issues/402 is solved
while ((currentDocs == null || currentDocs.isEmpty()) && retries > 0) {
while ((currentDocs == null || currentDocs.isEmpty()) && retries > 0 && !qidsToFetch.isEmpty()) {
try {
currentDocs = fetcher.getEntityDocuments(qidsToFetch);
} catch (MediaWikiApiErrorException e) {
@ -234,7 +234,7 @@ public class EditBatchProcessor {
}
retries--;
sleepTime *= backoff;
if ((currentDocs == null || currentDocs.isEmpty()) && retries > 0) {
if ((currentDocs == null || currentDocs.isEmpty()) && retries > 0 && !qidsToFetch.isEmpty()) {
logger.warn("Retrying in " + sleepTime + " ms");
Thread.sleep(sleepTime);
}