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:
Mads Jensen 2022-01-30 14:46:45 +01:00 committed by GitHub
parent 31a84d5b3d
commit ac92e047c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -2,7 +2,6 @@
import os
import socket
from collections import OrderedDict
from contextlib import contextmanager
from itertools import count, cycle
from operator import itemgetter
@ -658,7 +657,7 @@ class Connection:
def info(self):
"""Get connection info."""
return OrderedDict(self._info())
return dict(self._info())
def __eqhash__(self):
return HashedSeq(self.transport_cls, self.hostname, self.userid,

View File

@ -92,7 +92,6 @@ import socket
import ssl
import sys
import uuid
from collections import OrderedDict
from gettext import gettext as _
from queue import Empty
from time import monotonic
@ -189,7 +188,7 @@ class QoS:
def __init__(self, session, prefetch_count=1):
self.session = session
self.prefetch_count = 1
self._not_yet_acked = OrderedDict()
self._not_yet_acked = {}
def can_consume(self):
"""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.
Add a message, referenced by the delivery_tag, for ACKing,
rejecting, or getting later. Messages are saved into an
:class:`collections.OrderedDict` by delivery_tag.
rejecting, or getting later. Messages are saved into a
dict by delivery_tag.
:param message: A received message that has not yet been ACKed.
:type message: qpid.messaging.Message

View File

@ -177,6 +177,8 @@ class QoS:
self.channel = channel
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.restored = False
self._dirty = set()

View File

@ -4,7 +4,6 @@ import ssl
import sys
import time
import uuid
from collections import OrderedDict
from collections.abc import Callable
from itertools import count
from queue import Empty
@ -57,7 +56,7 @@ class test_QoS__init__:
assert qos_limit_two.prefetch_count == 1
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')