Skip to content

Commit

Permalink
Test if closing explicitly solves recursive lock issues
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk authored and jordankanter committed Mar 14, 2024
1 parent 1bebbce commit 7fbc8fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions spacy/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@ def prepare_input(
# is done, so that they can exit gracefully.
for q in texts_q:
q.put(_WORK_DONE_SENTINEL)
q.close()

# Otherwise, we are stopping because the error handler raised an
# exception. The sentinel will be last to go out of the queue.
Expand Down Expand Up @@ -2458,7 +2459,8 @@ def _apply_pipes(

# Stop working if we encounter the end-of-work sentinel.
if isinstance(texts_with_ctx, _WorkDoneSentinel):
return
sender.close()
receiver.close()

docs = (
ensure_doc(doc_like, context) for doc_like, context in texts_with_ctx
Expand All @@ -2482,7 +2484,8 @@ def _apply_pipes(
# Parent has closed the pipe prematurely. This happens when a
# worker encounters an error and the error handler is set to
# stop processing.
return
sender.close()
receiver.close()


class _Sender:
Expand Down

0 comments on commit 7fbc8fd

Please sign in to comment.