From f004c52275e62461c31afc3fce5e63d82e4c07e9 Mon Sep 17 00:00:00 2001 From: dzen Date: Thu, 5 Mar 2020 14:40:50 +0100 Subject: [PATCH 1/4] Use PLAIN auth method as others are not supported --- aioamqp/__init__.py | 4 ++-- aioamqp/protocol.py | 2 +- aioamqp/tests/test_protocol.py | 4 ++-- docs/changelog.rst | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aioamqp/__init__.py b/aioamqp/__init__.py index 3e67936..030e7db 100644 --- a/aioamqp/__init__.py +++ b/aioamqp/__init__.py @@ -10,7 +10,7 @@ async def connect(host='localhost', port=None, login='guest', password='guest', - virtualhost='/', ssl=None, login_method='AMQPLAIN', insist=False, + virtualhost='/', ssl=None, login_method='PLAIN', insist=False, protocol_factory=AmqpProtocol, *, loop=None, **kwargs): """Convenient method to connect to an AMQP broker @@ -69,7 +69,7 @@ async def connect(host='localhost', port=None, login='guest', password='guest', async def from_url( - url, login_method='AMQPLAIN', insist=False, protocol_factory=AmqpProtocol, **kwargs): + url, login_method='PLAIN', insist=False, protocol_factory=AmqpProtocol, **kwargs): """ Connect to the AMQP using a single url parameter and return the client. For instance: diff --git a/aioamqp/protocol.py b/aioamqp/protocol.py index ddf1285..e111dea 100644 --- a/aioamqp/protocol.py +++ b/aioamqp/protocol.py @@ -188,7 +188,7 @@ async def start_connection(self, host, port, login, password, virtualhost, ssl=F """ if login_method != 'PLAIN': - logger.warning('only PLAIN login_method is supported, falling back to AMQPLAIN') + logger.warning('login_method %s is not supported, falling back to PLAIN', login_method) self._stream_writer.write(amqp_constants.PROTOCOL_HEADER) diff --git a/aioamqp/tests/test_protocol.py b/aioamqp/tests/test_protocol.py index 766a5d9..80d4187 100644 --- a/aioamqp/tests/test_protocol.py +++ b/aioamqp/tests/test_protocol.py @@ -55,7 +55,7 @@ async def func(*x, **y): connect.assert_called_once_with( insist=False, password='pass', - login_method='AMQPLAIN', + login_method='PLAIN', login='tom', host='example.com', protocol_factory=AmqpProtocol, @@ -74,7 +74,7 @@ async def func(*x, **y): connect.assert_called_once_with( insist=False, password='pass', - login_method='AMQPLAIN', + login_method='PLAIN', ssl=ssl_context, login='tom', host='example.com', diff --git a/docs/changelog.rst b/docs/changelog.rst index 0939ca4..bd2822a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,8 @@ Changelog Next release ------------ + * Fix annoying auth method warning because of a wrong defined default argument (closes #214). + Aioamqp 0.14.0 -------------- From 388d38f28c6d5b7e6a50135de6b8ea9c44ccd6a6 Mon Sep 17 00:00:00 2001 From: mikmatko Date: Sat, 31 Oct 2020 12:13:27 +0200 Subject: [PATCH 2/4] Add support for Python 3.9. Drop support for Python 3.5. Update CI. --- .travis.yml | 6 +++--- Dockerfile | 2 +- docs/changelog.rst | 2 ++ docs/introduction.rst | 2 +- setup.cfg | 2 +- setup.py | 2 +- tox.ini | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1069e7c..9d6e4ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ language: python -dist: bionic +dist: focal python: -- 3.5 - 3.6 -- 3.7-dev +- 3.7 - 3.8 +- 3.9 services: - rabbitmq env: diff --git a/Dockerfile b/Dockerfile index 7ec4545..1ea92f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.5 +FROM python:3.9 WORKDIR /usr/src/app diff --git a/docs/changelog.rst b/docs/changelog.rst index bd2822a..8ac4f7b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,8 @@ Changelog Next release ------------ + * Add support for Python 3.9. + * Drop support for Python 3.5. * Fix annoying auth method warning because of a wrong defined default argument (closes #214). Aioamqp 0.14.0 diff --git a/docs/introduction.rst b/docs/introduction.rst index ec86f61..d0e183a 100644 --- a/docs/introduction.rst +++ b/docs/introduction.rst @@ -7,7 +7,7 @@ Aioamqp library is a pure-Python implementation of the AMQP 0.9.1 protocol using Prerequisites ------------- -Aioamqp works only with python >= 3.5 using asyncio library. +Aioamqp works only with python >= 3.6 using asyncio library. Installation ------------ diff --git a/setup.cfg b/setup.cfg index 0ab7d0b..9a9f5ab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [bdist_wheel] -python-tag = py35.py36.py37.py38 +python-tag = py36.py37.py38.py39 diff --git a/setup.py b/setup.py index a740243..ea0e79f 100644 --- a/setup.py +++ b/setup.py @@ -34,10 +34,10 @@ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], platforms='all', license='BSD' diff --git a/tox.ini b/tox.ini index 127cc7b..a1f5fcd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py35, py36, py37, py38 +envlist = py36, py37, py38, py39 skipsdist = true skip_missing_interpreters = true From 0cdfe91897f9125a05de91b3decd91d5503b12a3 Mon Sep 17 00:00:00 2001 From: mikmatko Date: Sat, 31 Oct 2020 12:48:04 +0200 Subject: [PATCH 3/4] Fix asyncio deprecation warnings --- aioamqp/channel.py | 4 ++-- aioamqp/protocol.py | 10 +++++----- aioamqp/tests/test_basic.py | 2 +- aioamqp/tests/test_connection_lost.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aioamqp/channel.py b/aioamqp/channel.py index 7f0f402..b58bd5a 100644 --- a/aioamqp/channel.py +++ b/aioamqp/channel.py @@ -31,7 +31,7 @@ def __init__(self, protocol, channel_id, return_callback=None): self.cancellation_callbacks = [] self.return_callback = return_callback self.response_future = None - self.close_event = asyncio.Event(loop=self._loop) + self.close_event = asyncio.Event() self.cancelled_consumers = set() self.last_consumer_tag = None self.publisher_confirms = False @@ -518,7 +518,7 @@ async def basic_consume_ok(self, frame): } future = self._get_waiter('basic_consume' + ctag) future.set_result(results) - self._ctag_events[ctag] = asyncio.Event(loop=self._loop) + self._ctag_events[ctag] = asyncio.Event() async def basic_deliver(self, frame): consumer_tag = frame.consumer_tag diff --git a/aioamqp/protocol.py b/aioamqp/protocol.py index e111dea..51b2b1d 100644 --- a/aioamqp/protocol.py +++ b/aioamqp/protocol.py @@ -79,7 +79,7 @@ def __init__(self, *args, **kwargs): self.connection_tunning['heartbeat'] = kwargs.get('heartbeat') self.connecting = asyncio.Future(loop=self._loop) - self.connection_closed = asyncio.Event(loop=self._loop) + self.connection_closed = asyncio.Event() self.stop_now = asyncio.Future(loop=self._loop) self.state = CONNECTING self.version_major = None @@ -91,14 +91,14 @@ def __init__(self, *args, **kwargs): self.server_heartbeat = None self._heartbeat_timer_recv = None self._heartbeat_timer_send = None - self._heartbeat_trigger_send = asyncio.Event(loop=self._loop) + self._heartbeat_trigger_send = asyncio.Event() self._heartbeat_worker = None self.channels = {} self.server_frame_max = None self.server_channel_max = None self.channels_ids_ceil = 0 self.channels_ids_free = set() - self._drain_lock = asyncio.Lock(loop=self._loop) + self._drain_lock = asyncio.Lock() def connection_made(self, transport): super().connection_made(transport) @@ -171,10 +171,10 @@ async def close(self, no_wait=False, timeout=None): await self.wait_closed(timeout=timeout) async def wait_closed(self, timeout=None): - await asyncio.wait_for(self.connection_closed.wait(), timeout=timeout, loop=self._loop) + await asyncio.wait_for(self.connection_closed.wait(), timeout=timeout) if self._heartbeat_worker is not None: try: - await asyncio.wait_for(self._heartbeat_worker, timeout=timeout, loop=self._loop) + await asyncio.wait_for(self._heartbeat_worker, timeout=timeout) except asyncio.CancelledError: pass diff --git a/aioamqp/tests/test_basic.py b/aioamqp/tests/test_basic.py index d59ce19..00ec880 100644 --- a/aioamqp/tests/test_basic.py +++ b/aioamqp/tests/test_basic.py @@ -58,7 +58,7 @@ async def callback(channel, body, envelope, _properties): result = await self.channel.publish("payload", exchange_name, routing_key='') - await asyncio.sleep(5, loop=self.loop) + await asyncio.sleep(5) result = await self.channel.queue_declare(queue_name, passive=True) self.assertEqual(result['message_count'], 1) diff --git a/aioamqp/tests/test_connection_lost.py b/aioamqp/tests/test_connection_lost.py index 21c7819..d16d51b 100644 --- a/aioamqp/tests/test_connection_lost.py +++ b/aioamqp/tests/test_connection_lost.py @@ -24,7 +24,7 @@ def callback(*args, **kwargs): self.assertEqual(amqp.state, OPEN) self.assertTrue(channel.is_open) amqp._stream_reader._transport.close() # this should have the same effect as the tcp connection being lost - await asyncio.wait_for(amqp.worker, 1, loop=self.loop) + await asyncio.wait_for(amqp.worker, 1) self.assertEqual(amqp.state, CLOSED) self.assertFalse(channel.is_open) self.assertTrue(self.callback_called) From b4f01209794122a4ec3b5d8d437cb5739641fb3e Mon Sep 17 00:00:00 2001 From: mikmatko Date: Sat, 31 Oct 2020 13:10:15 +0200 Subject: [PATCH 4/4] Fix pylint warning W0707(raise-missing-from) --- aioamqp/protocol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aioamqp/protocol.py b/aioamqp/protocol.py index 51b2b1d..75d1815 100644 --- a/aioamqp/protocol.py +++ b/aioamqp/protocol.py @@ -456,11 +456,11 @@ async def channel(self, **kwargs): await self.ensure_open() try: channel_id = self.channels_ids_free.pop() - except KeyError: + except KeyError as ex: assert self.server_channel_max is not None, 'connection channel-max tuning not performed' # channel-max = 0 means no limit if self.server_channel_max and self.channels_ids_ceil > self.server_channel_max: - raise exceptions.NoChannelAvailable() + raise exceptions.NoChannelAvailable() from ex self.channels_ids_ceil += 1 channel_id = self.channels_ids_ceil channel = self.CHANNEL_FACTORY(self, channel_id, **kwargs)