#NEWLINE# def _SortByPriority( self , notifications , queue , output_dict = None ) : #NEWLINE# #INDENT# 'Sort notifications by priority into output_dict.' #NEWLINE# if ( output_dict is None ) : #NEWLINE# #INDENT# output_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# for notification in notifications : #NEWLINE# #INDENT# priority = notification . priority #NEWLINE# if notification . in_progress : #NEWLINE# #INDENT# priority = self . STUCK_PRIORITY #NEWLINE# #UNINDENT# output_dict . setdefault ( priority , [ ] ) . append ( notification ) #NEWLINE# #UNINDENT# for priority in output_dict : #NEWLINE# #INDENT# stats . STATS . SetGaugeValue ( 'notification_queue_count' , len ( output_dict [ priority ] ) , fields = [ queue . Basename ( ) , str ( priority ) ] ) #NEWLINE# random . shuffle ( output_dict [ priority ] ) #NEWLINE# #UNINDENT# return output_dict