From fc46c67a7f891a618ff93a77ef6b9a43fbd9060d Mon Sep 17 00:00:00 2001 From: Hassan Mkhallati <48966000+Hmkhalla@users.noreply.github.com> Date: Sun, 13 Nov 2022 09:49:40 +0100 Subject: [PATCH] fixing concurrent work and input matching See the example in https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor-example --- spacyopentapioca/entity_linker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacyopentapioca/entity_linker.py b/spacyopentapioca/entity_linker.py index fb9eac5..972af8b 100644 --- a/spacyopentapioca/entity_linker.py +++ b/spacyopentapioca/entity_linker.py @@ -115,5 +115,6 @@ def pipe(self, stream, batch_size=128): with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor: future_to_url = {executor.submit( self.make_request, doc): doc for doc in docs} - for doc, future in zip(docs, concurrent.futures.as_completed(future_to_url)): + for future in concurrent.futures.as_completed(future_to_url): + doc = future_to_url[future] yield self.process_single_doc_after_call(doc, future.result())