Skip to content

Commit

Permalink
fix: fix access to doclist
Browse files Browse the repository at this point in the history
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
  • Loading branch information
JoanFM committed Oct 3, 2023
1 parent c6d4870 commit 1004f02
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jina/serve/runtimes/worker/batch_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,16 @@ def batch(iterable, n=1):
yield iterable[ndx: min(ndx + n, items)]

await self._flush_trigger.wait()

# writes to shared data between tasks need to be mutually exclusive
async with self._data_lock:
filled_requests = 0
try:
if not docarray_v2:
return_docs: DocumentArray = DocumentArray.empty()
non_distributed_docs: DocumentArray = DocumentArray.empty()
else:
return_docs = self._out_docarray_cls()
non_distributed_docs = self._out_docarray_cls()

Check warning on line 147 in jina/serve/runtimes/worker/batch_queue.py

View check run for this annotation

Codecov / codecov/patch

jina/serve/runtimes/worker/batch_queue.py#L146-L147

Added lines #L146 - L147 were not covered by tests

filled_requests = 0
for docs in batch(self._big_doc, self._preferred_batch_size):
input_len_before_call: int = len(docs)
try:
Expand Down Expand Up @@ -192,11 +190,13 @@ def batch(iterable, n=1):
filled_requests += len(request_buckets)
non_distributed_docs = batch_res_docs[
num_distributed_docs_in_batch:] if batch_res_docs is not None else docs[
num_distributed_docs_in_batch]
num_distributed_docs_in_batch:]

except Exception as exc:
# All the requests containing docs in this Exception should be raising it
raise exc
# TODO: Handle exceptions properly
for request_full in self._requests_full[filled_requests:]:
await request_full.put(exc)
finally:
self._reset()

Expand Down

0 comments on commit 1004f02

Please sign in to comment.