You can add a while loop to make it run a certain number of times. Be careful in python not to exceed the maximum recursion depth which I believe is around 1000.
count=0
def fooBar():
global count
count = count+1
if count==0:
print('bar ',count)
while count < 999:
return fooBar()
elif(count%4 == 0):
print('foo ',count)
while count < 999:
return fooBar()
else:
print('bar ',count)
while count < 999:
return fooBar()
fooBar()