diff options
author | Zuul <zuul@review.openstack.org> | 2017-11-29 19:43:46 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-11-29 19:43:46 +0000 |
commit | c7eb5cac660e4cbe46749491a244c821aced842e (patch) | |
tree | c44bfa4fe6faa72c1685cc3348e9e7882d431d79 /oslo_messaging/notify | |
parent | d0a3f70966153e7fa494cc5bb06b553da1d59c15 (diff) | |
parent | b8a686fc520d38f2b71b450d7c615c09be9eb1d2 (diff) | |
download | oslo-messaging-c7eb5cac660e4cbe46749491a244c821aced842e.tar.gz |
Merge "sort when using groupby"
Diffstat (limited to 'oslo_messaging/notify')
-rw-r--r-- | oslo_messaging/notify/dispatcher.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/oslo_messaging/notify/dispatcher.py b/oslo_messaging/notify/dispatcher.py index 83b3fe4..dedb7e2 100644 --- a/oslo_messaging/notify/dispatcher.py +++ b/oslo_messaging/notify/dispatcher.py @@ -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: |