MCPcopy Index your code
hub / github.com/webpy/webpy / safeiter

Function safeiter

web/utils.py:729–743  ·  view source on GitHub ↗

Makes an iterator safe by ignoring the exceptions occurred during the iteration.

(it, cleanup=None, ignore_errors=True)

Source from the content-addressed store, hash-verified

727
728
729def safeiter(it, cleanup=None, ignore_errors=True):
730 """Makes an iterator safe by ignoring the exceptions occurred during the iteration."""
731
732 def next():
733 while True:
734 try:
735 return next(it)
736 except StopIteration:
737 raise
738 except:
739 traceback.print_exc()
740
741 it = iter(it)
742 while True:
743 yield next()
744
745
746def safewrite(filename, content):

Callers

nothing calls this directly

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected