question 312 Iterators & Generators · hard
The event stream that stops and forgets
clean_events(lines) turns raw JSON lines into small event records, dropping repeated event ids. Two bugs were reported: the stream ends at the first corrupted line instead of skipping it, and when the import job runs a second time in the same process, the second run returns almost nothing. Fix both.
Generator
clean_events(lines)Yields
{"id", "type", "repo"} for each valid line whose id hasn't been seen in this callSkipslines that aren't valid JSON, and repeated ids