Rework map_async to handle failures better#495
Merged
martindurant merged 5 commits intopython-streamz:masterfrom Jan 21, 2026
Merged
Rework map_async to handle failures better#495martindurant merged 5 commits intopython-streamz:masterfrom
martindurant merged 5 commits intopython-streamz:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mapstops the flow of items in the stream when the function raises butmap_asyncis outside of the direct line of return so it fails weirdly during an exception. To address that, I added the idea about stopping the stream or not. This way, if the stream does not deliberately invokestopduring an exception, the stream continues to process inputs after an exception.Since the
map_asyncnow conceives of stopping or not, I added a boolean in the node state to control the loop inside the worker task.In the case of an exception during mapping,
map_asyncwill now release the references held on the metadata for the offending input.I added an example that shows off the failure modes of
mapandmap_asyncthat plainly demonstrates that exceptions can leave the stream in a weird state.