runtime
312 / 500
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.

Generatorclean_events(lines)
Yields{"id", "type", "repo"} for each valid line whose id hasn't been seen in this call
Skipslines that aren't valid JSON, and repeated ids

Loading your progress…

The event stream that stops and forgets — Python practice · Runtime