Skip to content

Instantly share code, notes, and snippets.

@malanjp
Created May 1, 2013 05:44
Show Gist options
  • Save malanjp/5493922 to your computer and use it in GitHub Desktop.
Save malanjp/5493922 to your computer and use it in GitHub Desktop.
import sys, time
sys.setrecursionlimit(10)
def gen1():
count = 0
while True:
count = count + 1
print count
if count > 10:
return
if count == 5:
print 'raise!'
raise Exception
yield count
counter = gen1()
def iterate(counter):
try:
count = counter.next()
except Exception:
print 'except'
time.sleep(1.0)
return iterate(counter)
print count
return iterate(counter)
iterate(counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment