diff --git a/mqtt_io/config/config.schema.yml b/mqtt_io/config/config.schema.yml index 59b1d3a9..3bb138e6 100644 --- a/mqtt_io/config/config.schema.yml +++ b/mqtt_io/config/config.schema.yml @@ -129,10 +129,10 @@ mqtt: description: MQTT Client implementation module path. extra_info: | There's currently only one implementation, which uses the - [asyncio-mqtt](https://github.com/sbtinstruments/asyncio-mqtt/) client. + [aiomqtt](https://github.com/sbtinstruments/aiomqtt/) client. type: string required: no - default: mqtt_io.mqtt.asyncio_mqtt + default: mqtt_io.mqtt.aiomqtt ha_discovery: type: dict required: no diff --git a/mqtt_io/mqtt/asyncio_mqtt.py b/mqtt_io/mqtt/aiomqtt.py similarity index 95% rename from mqtt_io/mqtt/asyncio_mqtt.py rename to mqtt_io/mqtt/aiomqtt.py index 55187106..579d3a43 100644 --- a/mqtt_io/mqtt/asyncio_mqtt.py +++ b/mqtt_io/mqtt/aiomqtt.py @@ -8,7 +8,7 @@ from functools import wraps from typing import Any, Callable, List, Optional, Tuple, TypeVar, cast -from asyncio_mqtt.client import Client, MqttError, Will # type: ignore +from aiomqtt.client import Client, MqttError, Will # type: ignore from paho.mqtt import client as paho # type: ignore from . import ( @@ -93,7 +93,7 @@ def __init__(self, options: MQTTClientOptions): port=options.port, username=options.username, password=options.password, - client_id=options.client_id, + identifier=options.client_id, #keepalive=options.keepalive, tls_context=tls_context, protocol=protocol_map[options.protocol], @@ -113,7 +113,7 @@ async def connect(self, timeout: int = 10) -> None: Returns: None: This function does not return anything. """ - await self._client.connect(timeout=timeout) + await self._client.__aenter__() @_map_exception async def disconnect(self) -> None: @@ -126,10 +126,7 @@ async def disconnect(self) -> None: Returns: None """ - try: - await self._client.disconnect() - except TimeoutError: - await self._client.force_disconnect() + await self._client.__aexit__(None, None, None) @_map_exception async def subscribe(self, topics: List[Tuple[str, int]]) -> None: diff --git a/mqtt_io/server.py b/mqtt_io/server.py index 2b87a12b..259f398c 100644 --- a/mqtt_io/server.py +++ b/mqtt_io/server.py @@ -18,7 +18,7 @@ from hashlib import sha1 from importlib import import_module from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload -from asyncio_mqtt.error import MqttCodeError # type: ignore +from aiomqtt.exceptions import MqttCodeError # type: ignore import backoff # type: ignore from typing_extensions import Literal diff --git a/pyproject.toml b/pyproject.toml index 64872603..754a2ecf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,12 +8,12 @@ license = "MIT" documentation = "https://flyte.github.io/mqtt-io/" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.8" PyYAML = "^6.0.1" Cerberus = "^1.3.2" -typing-extensions = "^3.7.4" +typing-extensions = "^4.4.0" dataclasses = { version = "^0.8", python = ">=3.6,<3.7" } -asyncio-mqtt = "^0.8.1" +aiomqtt = "^2.0.1" backoff = "^1.10.0" confp = "^0.4.0" @@ -25,11 +25,11 @@ pylint = "^2.6.2" mypy = "^0.812" behave = "^1.2.6" coverage = "^5.4" -md-toc = "^7.1.0" +md-toc = "^8.0.0" Sphinx = "^3.5.1" sphinx-autoapi = "^1.7.0" recommonmark = "^0.7.1" -Jinja2 = "^2.11.3" +Jinja2 = "^3.1.3" ast-to-xml="^0.2.3" GitPython = "^3.1.15" semver = "^2.13.0"