Commit 09969c5
committed
Rework map_async to handle failures better
`map` stops the flow of items in the stream when the function raises but
`map_async` is 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 invoke
`stop` during an exception, the stream continues to process inputs after
an exception.
Since the `map_async` now 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_async` will now release
the references held on the metadata for the offending input.
I added an example that shows off the failure modes of `map` and
`map_async` that plainly demonstrates that exceptions can leave the
stream in a weird state.1 parent 3e0beab commit 09969c5
2 files changed
+61
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
730 | 730 | | |
731 | 731 | | |
732 | 732 | | |
| 733 | + | |
| 734 | + | |
733 | 735 | | |
734 | 736 | | |
735 | 737 | | |
| |||
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
752 | | - | |
| 754 | + | |
753 | 755 | | |
754 | 756 | | |
755 | 757 | | |
756 | 758 | | |
| 759 | + | |
| 760 | + | |
757 | 761 | | |
758 | 762 | | |
759 | 763 | | |
760 | 764 | | |
761 | 765 | | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
762 | 771 | | |
763 | 772 | | |
764 | 773 | | |
| |||
768 | 777 | | |
769 | 778 | | |
770 | 779 | | |
771 | | - | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
772 | 783 | | |
773 | | - | |
774 | | - | |
775 | 784 | | |
776 | 785 | | |
777 | 786 | | |
778 | | - | |
| 787 | + | |
| 788 | + | |
779 | 789 | | |
780 | 790 | | |
781 | 791 | | |
782 | 792 | | |
783 | | - | |
| 793 | + | |
784 | 794 | | |
785 | 795 | | |
786 | 796 | | |
| |||
0 commit comments