Skip to content

Instantly share code, notes, and snippets.

@AaronTorgerson
Created December 4, 2015 19:25
Show Gist options
  • Save AaronTorgerson/3ff405b1d246303cd9bc to your computer and use it in GitHub Desktop.
Save AaronTorgerson/3ff405b1d246303cd9bc to your computer and use it in GitHub Desktop.

Revisions

  1. AaronTorgerson created this gist Dec 4, 2015.
    12 changes: 12 additions & 0 deletions iterate_models_safely.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    import sys

    t = MyThing.objects.iterator()
    while True:
    try:
    record = it.next()
    sys.stdout.write('.')
    except StopIteration:
    break
    except Exception as ex:
    sys.stdout.write('x')