tweak StatefulStreamWorker interface

This commit is contained in:
simon987 2021-09-19 14:19:17 -04:00
parent f4a5e6cf53
commit c560cc2010
2 changed files with 6 additions and 3 deletions

View File

@ -13,15 +13,18 @@ class StatefulStreamWorker:
def run(self, q: Queue):
for chunk in queue_iter(q, joinable=False, timeout=3):
self.process_chunk(chunk)
self._process_chunk(chunk)
def process_chunk(self, chunk):
def _process_chunk(self, chunk):
for item in chunk:
self.process(item)
def process(self, item) -> None:
raise NotImplementedError
def results(self):
raise NotImplementedError
class StatefulStreamProcessor:
def __init__(self, worker_factory, chunk_size=128, processes=1):

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="hexlib",
version="1.54",
version="1.55",
description="Misc utility methods",
author="simon987",
author_email="me@simon987.net",