Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions fastembed/parallel_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ def semi_ordered_map(
# join would wait forever for processes blocked on the input queue.
self.emergency_shutdown = True
self.join_or_terminate()
# Nothing reads the input pipe anymore, so the feeder thread can be stuck writing to it,
# holding every batch it hasn't sent. Closing our read end fails that write with EPIPE and
# lets the thread exit, same as Queue._terminate_broken() in python 3.12+.
self.input_queue._reader.close() # type: ignore[attr-defined]
# Nothing reads the input pipe anymore, so the feeder thread can be stuck
# writing to it, holding every item it hasn't sent. On POSIX, closing our
# read end fails that write with EPIPE; Windows also needs to cancel the send.
terminate_broken = getattr(self.input_queue, "_terminate_broken", None)
if terminate_broken is not None:
terminate_broken()
else:
self.input_queue._reader.close() # type: ignore[attr-defined]
self.input_queue.close()
self.output_queue.close()
if self.emergency_shutdown:
Expand Down
Loading