mirror of https://github.com/celery/kombu.git
Remove use of OrderedDict in various places (#1483)
* Remove use of OrderedDict in Connection.info. * Remove remnant use of collections.OrderedDict * Undo QoS._delivered move to Python standard dictionary. This requires more work to convert, due to a hack in how the dictionary is used. * Undo LRUCache.data to dict conversion. It's also problematic, and caused tests to fail. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert QoS._delivered comment chagne. * Update comment Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
31a84d5b3d
commit
ac92e047c1
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
from collections import OrderedDict
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from itertools import count, cycle
|
from itertools import count, cycle
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
@ -658,7 +657,7 @@ class Connection:
|
||||||
|
|
||||||
def info(self):
|
def info(self):
|
||||||
"""Get connection info."""
|
"""Get connection info."""
|
||||||
return OrderedDict(self._info())
|
return dict(self._info())
|
||||||
|
|
||||||
def __eqhash__(self):
|
def __eqhash__(self):
|
||||||
return HashedSeq(self.transport_cls, self.hostname, self.userid,
|
return HashedSeq(self.transport_cls, self.hostname, self.userid,
|
||||||
|
|
|
@ -92,7 +92,6 @@ import socket
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
from collections import OrderedDict
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from queue import Empty
|
from queue import Empty
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
@ -189,7 +188,7 @@ class QoS:
|
||||||
def __init__(self, session, prefetch_count=1):
|
def __init__(self, session, prefetch_count=1):
|
||||||
self.session = session
|
self.session = session
|
||||||
self.prefetch_count = 1
|
self.prefetch_count = 1
|
||||||
self._not_yet_acked = OrderedDict()
|
self._not_yet_acked = {}
|
||||||
|
|
||||||
def can_consume(self):
|
def can_consume(self):
|
||||||
"""Return True if the :class:`Channel` can consume more messages.
|
"""Return True if the :class:`Channel` can consume more messages.
|
||||||
|
@ -229,8 +228,8 @@ class QoS:
|
||||||
"""Append message to the list of un-ACKed messages.
|
"""Append message to the list of un-ACKed messages.
|
||||||
|
|
||||||
Add a message, referenced by the delivery_tag, for ACKing,
|
Add a message, referenced by the delivery_tag, for ACKing,
|
||||||
rejecting, or getting later. Messages are saved into an
|
rejecting, or getting later. Messages are saved into a
|
||||||
:class:`collections.OrderedDict` by delivery_tag.
|
dict by delivery_tag.
|
||||||
|
|
||||||
:param message: A received message that has not yet been ACKed.
|
:param message: A received message that has not yet been ACKed.
|
||||||
:type message: qpid.messaging.Message
|
:type message: qpid.messaging.Message
|
||||||
|
|
|
@ -177,6 +177,8 @@ class QoS:
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.prefetch_count = prefetch_count or 0
|
self.prefetch_count = prefetch_count or 0
|
||||||
|
|
||||||
|
# Standard Python dictionaries do not support setting attributes
|
||||||
|
# on the object, hence the use of OrderedDict
|
||||||
self._delivered = OrderedDict()
|
self._delivered = OrderedDict()
|
||||||
self._delivered.restored = False
|
self._delivered.restored = False
|
||||||
self._dirty = set()
|
self._dirty = set()
|
||||||
|
|
|
@ -4,7 +4,6 @@ import ssl
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from collections import OrderedDict
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from itertools import count
|
from itertools import count
|
||||||
from queue import Empty
|
from queue import Empty
|
||||||
|
@ -57,7 +56,7 @@ class test_QoS__init__:
|
||||||
assert qos_limit_two.prefetch_count == 1
|
assert qos_limit_two.prefetch_count == 1
|
||||||
|
|
||||||
def test__init___not_yet_acked_is_initialized(self):
|
def test__init___not_yet_acked_is_initialized(self):
|
||||||
assert isinstance(self.qos._not_yet_acked, OrderedDict)
|
assert isinstance(self.qos._not_yet_acked, dict)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason='Not supported in Python3')
|
@pytest.mark.skip(reason='Not supported in Python3')
|
||||||
|
|
Loading…
Reference in New Issue