Created
May 1, 2013 05:44
-
-
Save malanjp/5493922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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