#NEWLINE# def drain_queue( self , queue_name , json = False ) : #NEWLINE# #INDENT# 'Returns all messages in the desired queue' #NEWLINE# messages = [ ] #NEWLINE# def opened( ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# ( meta , _ , message ) = self . channel . basic_get ( queue_name ) #NEWLINE# if ( not message ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# self . channel . basic_ack ( meta . delivery_tag ) #NEWLINE# if json : #NEWLINE# #INDENT# message = ujson . loads ( message ) #NEWLINE# #UNINDENT# messages . append ( message ) #NEWLINE# #UNINDENT# #UNINDENT# self . ensure_queue ( self , opened ) #NEWLINE# return messages