mirror of
https://github.com/simon987/hexlib.git
synced 2025-04-10 14:06:43 +00:00
tweak StatefulStreamWorker interface
This commit is contained in:
parent
f4a5e6cf53
commit
c560cc2010
@ -13,15 +13,18 @@ class StatefulStreamWorker:
|
|||||||
|
|
||||||
def run(self, q: Queue):
|
def run(self, q: Queue):
|
||||||
for chunk in queue_iter(q, joinable=False, timeout=3):
|
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:
|
for item in chunk:
|
||||||
self.process(item)
|
self.process(item)
|
||||||
|
|
||||||
def process(self, item) -> None:
|
def process(self, item) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def results(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class StatefulStreamProcessor:
|
class StatefulStreamProcessor:
|
||||||
def __init__(self, worker_factory, chunk_size=128, processes=1):
|
def __init__(self, worker_factory, chunk_size=128, processes=1):
|
||||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="hexlib",
|
name="hexlib",
|
||||||
version="1.54",
|
version="1.55",
|
||||||
description="Misc utility methods",
|
description="Misc utility methods",
|
||||||
author="simon987",
|
author="simon987",
|
||||||
author_email="me@simon987.net",
|
author_email="me@simon987.net",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user