#NEWLINE# @ inlineCallbacks #NEWLINE# def on_event( self , i ) : #NEWLINE# #INDENT# print ( 'Got event: {}' . format ( i ) ) #NEWLINE# self . received += 1 #NEWLINE# if ( self . received > 5 ) : #NEWLINE# #INDENT# self . runs += 1 #NEWLINE# if ( self . runs > 1 ) : #NEWLINE# #INDENT# self . leave ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield self . sub . unsubscribe ( ) ) #NEWLINE# print ( 'Unsubscribed .. continue in 5s ..' ) #NEWLINE# reactor . callLater ( 5 , self . test )