#NEWLINE# def test_queue_message_handler_queue( self ) : #NEWLINE# #INDENT# received = { #NEWLINE# #INDENT# 'msgs' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# def cb( msg ) : #NEWLINE# #INDENT# received [ 'msgs' ] . append ( msg ) #NEWLINE# #UNINDENT# msgs = range ( 1000 ) #NEWLINE# handler = subscribe . MessageHandler ( None , cb ) #NEWLINE# handler = handler . set_throttle_rate ( 10000 ) #NEWLINE# handler = handler . set_queue_length ( 10 ) #NEWLINE# self . assertIsInstance ( handler , subscribe . QueueMessageHandler ) #NEWLINE# handler . handle_message ( 'hello' ) #NEWLINE# time . sleep ( 0.02 ) #NEWLINE# for x in msgs : #NEWLINE# #INDENT# handler . handle_message ( x ) #NEWLINE# #UNINDENT# handler = handler . set_throttle_rate ( 0 ) #NEWLINE# time . sleep ( 0.1 ) #NEWLINE# try : #NEWLINE# #INDENT# self . assertEqual ( ( [ 'hello' ] + range ( 990 , 1000 ) ) , received [ 'msgs' ] ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# handler . finish ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# handler . finish ( )