sort when using groupby
groupby requires items to be sorted as it's clumping consecutive items together. also, just use itemgetter instead of lambda Change-Id: I1676fc60ebc2c9ff03ea00cc67061fdfb3b50868
This commit is contained in:
parent
02056bfb12
commit
b8a686fc52
@ -16,6 +16,7 @@
|
||||
|
||||
import itertools
|
||||
import logging
|
||||
import operator
|
||||
|
||||
import six
|
||||
|
||||
@ -118,9 +119,9 @@ class BatchNotificationDispatcher(NotificationDispatcher):
|
||||
"""Dispatch notification messages to the appropriate endpoint method.
|
||||
"""
|
||||
|
||||
messages_grouped = itertools.groupby((
|
||||
self._extract_user_message(m)
|
||||
for m in incoming), lambda x: x[0])
|
||||
messages_grouped = itertools.groupby(sorted(
|
||||
(self._extract_user_message(m) for m in incoming),
|
||||
key=operator.itemgetter(0)), operator.itemgetter(0))
|
||||
|
||||
requeues = set()
|
||||
for priority, messages in messages_grouped:
|
||||
|
Loading…
Reference in New Issue
Block a user