Skip to content

Commit

Permalink
Introduce max_iterations for _get_all_iterative_for_uris()
Browse files Browse the repository at this point in the history
  • Loading branch information
gergely-ujvari committed Feb 4, 2015
1 parent 389dc0d commit d53fcfa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion annotator/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
}
}
}
MAX_ITERATIONS = 5


class Document(es.Model):
Expand Down Expand Up @@ -93,8 +94,9 @@ def _get_all_iterative_for_uris(cls, uris):
documents = {}
all_uris = set(uris)
new_uris = list(uris)
iterations = 0

while len(new_uris):
while len(new_uris) and iterations < MAX_ITERATIONS:
docs = cls._get_all_by_uris(new_uris)
new_uris = []
for doc in docs:
Expand All @@ -105,6 +107,7 @@ def _get_all_iterative_for_uris(cls, uris):
if uri not in all_uris:
new_uris.append(uri)
all_uris.add(uri)
iterations += 1

return list(documents.values())

Expand Down

0 comments on commit d53fcfa

Please sign in to comment.