diff --git a/CHANGELOG.md b/CHANGELOG.md index 33d80fc7bad49d70b5aec73065d83d515371c148..e2d55be1109a30fa8b60c28dd149d589a595005d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,4 +7,5 @@ Since v1.3.2 they'll be put here and in release description. * compile_definitions will now depend on requests * added support for infinite (None) timeouts during start * stress tests will run for 120 seconds now -* stress tests will be harder, and use more queues \ No newline at end of file +* stress tests will be harder, and use more queues +* added extra __slots__ in Declarer \ No newline at end of file diff --git a/coolamqp/__init__.py b/coolamqp/__init__.py index 9f915c8fcfb4069ff0eb206eb984242c7d7e45b9..19efb0b4a9ca9696428bc90b9a9c018f6609e835 100644 --- a/coolamqp/__init__.py +++ b/coolamqp/__init__.py @@ -1 +1 @@ -__version__ = '1.3.2b3' +__version__ = '1.3.2b4' diff --git a/coolamqp/attaches/declarer.py b/coolamqp/attaches/declarer.py index e308debad5df9c713dcc178a8ef278f911ebe533..92601c5f2b0a8bc4e9d8faded5a2d802ac52cbf2 100644 --- a/coolamqp/attaches/declarer.py +++ b/coolamqp/attaches/declarer.py @@ -150,6 +150,9 @@ class Operation(object): class DeleteQueue(Operation): + + __slots__ = () + def __init__(self, declarer, queue, fut, span_parent=None, span_enqueued=None): super(DeleteQueue, self).__init__(declarer, queue, fut=fut, span_parent=span_parent, span_enqueued=span_enqueued) @@ -181,6 +184,7 @@ class Declarer(Channeler, Synchronized): This also maintains a list of declared queues/exchanges, and redeclares them on each reconnect. """ + __slots__ = ('in_process', 'on_discard', 'left_to_declare', 'declared', 'cluster') def __init__(self, cluster): """ diff --git a/coolamqp/attaches/utils.py b/coolamqp/attaches/utils.py index 33dbfdf6f58c47d4015e1e3b5996b0862ad798eb..70dc6d1b8197b903f1c709fb0a27ef611557d493 100644 --- a/coolamqp/attaches/utils.py +++ b/coolamqp/attaches/utils.py @@ -13,14 +13,14 @@ def close_future(fut, span): # type: (Future, opentracing.Span) -> Future """ To be called as a Future callback, means to close the span """ + if span is None: + return fut + try: import opentracing except ImportError: return fut - if span is None: - return fut - def inner_close(fut): # type: (Future) -> None exc = fut.exception() if exc is not None: @@ -251,6 +251,7 @@ class Synchronized(object): ... """ + __slots__ = ('_monitor_lock', ) def __init__(self): self._monitor_lock = threading.Lock() diff --git a/tests/test_attaches/test_declarer.py b/tests/test_attaches/test_declarer.py new file mode 100644 index 0000000000000000000000000000000000000000..6cc73b10896b6949db1eac7a573fe957dea65b45 --- /dev/null +++ b/tests/test_attaches/test_declarer.py @@ -0,0 +1,13 @@ +import unittest + +from coolamqp.attaches import Declarer + + +class TestDeclarer(unittest.TestCase): + def test_declarer_slots(self): + """Test that __slots__ are respected""" + d = Declarer(None) + def add_argument(): + d.extra_argument = False + + self.assertRaises(AttributeError, add_argument)