def Scheduler
try:
	yield from ping();
	yield from pong();
except StopIteration:
	print( "Scheduler stop" )


def pong():
	print( "pong" )
for i in range( 10 ):

		yield from ping()
	print( "stop pong" )

def ping():
	global i
	print( "ping" )
	i += 1
	if i < 5:
		yield from pong()
	print( "stop ping" )

p = ping()
try:
	next( p )
except StopIteration:
	print( "stop" )

# Local Variables: #
# tab-width: 4 #
# compile-command: "python3.5 pingpong.py" #
# End: #
