From 7fbc8fd703f0f1d3d4ab91684f0939b4ed443e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= Date: Fri, 2 Feb 2024 11:39:07 +0100 Subject: [PATCH] Test if closing explicitly solves recursive lock issues --- spacy/language.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index 77714b9518c..9ada4f98c80 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -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. @@ -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 @@ -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: