Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save multiple output when iteration stops in PostOffice #852

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions strax/processors/post_office.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PostOffice:

#: Set of topics that are multi output
#: (i.e. the producer makes topic -> message dicts)
_multi_output_topics: ty.Set[str]
_multi_output_topics: ty.Dict[str, ty.Tuple[str]]

# Dict: topic -> list with (msg_number, msg)
_saved_mail: ty.Dict[str, ty.List[ty.Tuple[int, ty.Any]]]
Expand All @@ -81,8 +81,7 @@ class PostOffice:
def __init__(self):
self.time_spent = dict()
self._exhausted_topics = set()
self._multi_output_topics = set()

self._multi_output_topics = dict()
self._saved_mail = dict()
self._spies = dict()
self._producers = dict()
Expand Down Expand Up @@ -128,7 +127,7 @@ def register_producer(self, iterator: ty.Iterator[ty.Any], topic: ty.Union[str,
else:
# Multi-output producer, recurse
for sub_topic in topic:
self._multi_output_topics.add(sub_topic)
self._multi_output_topics[sub_topic] = topic
self.register_producer(iterator, sub_topic)
return
assert isinstance(topic, str)
Expand Down Expand Up @@ -241,7 +240,8 @@ def _fetch_new(self, topic):
try:
msg = next(self._producers[topic])
except StopIteration:
self._ack_topic_exhausted(topic)
for sub_topic in self._multi_output_topics.get(topic, [topic]):
self._ack_topic_exhausted(sub_topic)
# reraise to end the generator in _read
raise StopIteration

Expand Down
2 changes: 1 addition & 1 deletion strax/processors/single_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(

dtypes_built = {d: p for p in components.plugins.values() for d in p.provides}
for d, savers in components.savers.items():
for s_i, saver in enumerate(savers):
for saver in savers:
if d in dtypes_built:
rechunk = dtypes_built[d].can_rechunk(d) and allow_rechunk
else:
Expand Down