Skip to content

Commit

Permalink
Update _BaseWorker to avoid creating a new Pipeline in the main t…
Browse files Browse the repository at this point in the history
…hread
  • Loading branch information
althonos committed Oct 14, 2024
1 parent 2bcb411 commit cedae6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pyhmmer/hmmer/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ def __init__(
super().__init__()
self.options = options
self.targets: _T = targets
self.pipeline = pipeline_class(**options)
self.pipeline = None
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]] = (
Expand Down Expand Up @@ -310,6 +312,8 @@ def process(self, query: _Q) -> _R:
"""Process a single query and return the resulting hits."""
if isinstance(self.targets, (HMMPressedFile, SequenceFile)):
self.targets.rewind()
if self.pipeline is None:
self.pipeline = self.pipeline_class(**self.pipeline_options)
hits = self.query(query)
self.callback(query, self.query_count.value) # type: ignore
self.pipeline.clear()
Expand Down

0 comments on commit cedae6c

Please sign in to comment.