From a3325be32c94e199aa574b715b68758d8c940d61 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 14 Oct 2024 17:41:50 +0200 Subject: [PATCH] Update `_BaseWorker` to avoid creating a new `Pipeline` in the main thread --- src/pyhmmer/hmmer/_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pyhmmer/hmmer/_base.py b/src/pyhmmer/hmmer/_base.py index d0b8baa..0ede444 100644 --- a/src/pyhmmer/hmmer/_base.py +++ b/src/pyhmmer/hmmer/_base.py @@ -255,7 +255,9 @@ def __init__( super().__init__() self.options = options self.targets: _T = targets - self.pipeline = pipeline_class(**options) + # self.pipeline = pipeline_class(**options) + self.pipeline_options = options + self.pipeline_class = pipeline_class self.query_queue: "queue.Queue[typing.Optional[_BaseChore[_Q, _R]]]" = query_queue self.query_count = query_count self.callback: typing.Optional[typing.Callable[[_Q, int], None]] = ( @@ -265,6 +267,7 @@ def __init__( self.builder = builder def run(self) -> None: + self.pipeline = self.pipeline_class(**self.pipeline_options) while not self.is_killed(): # attempt to get the next argument, with a timeout # so that the thread can periodically check if it has