Package: release.debian.org Severity: normal Tags: bullseye User: release.debian....@packages.debian.org Usertags: pu X-Debbugs-Cc: team+pyt...@tracker.debian.org
Control: found 998912 0.9.6-1 Control: forwarded 998912 https://github.com/beerfactory/hbmqtt/issues/223 python3-hbmqtt can be used for connecting to a mqtt broker or for running a mqtt broker. I guess that the former is more widespread. The version of python3-hbmqtt cannot connect to a broker at all. [ Reason ] In python the way asyncio Lock objects can be used has changed. This results in a traceback when the hbmqtt client attempts to acquire such a Lock object. For full details, please refer to 998912. [ Impact ] Any attempt to connect to a mqtt broker using the hbmqtt client fails. This renders hbmqtt mostly unusable. The fact that nobody noticed suggests that few people use hbmqtt. [ Tests ] If the code had been tested, this would likely have been noticed earlier. The version in unstable now has autopkgtests to cover for this, but adding such tests in stable does not seem reasonable to me. If you run a mqtt broker on localhost (e.g. mosquitto), the following command can be used to test for the issue: python3 -c 'from hbmqtt.client import MQTTClient as C; __import__("asyncio").get_event_loop().run_until_complete(C().connect("mqtt://localhost"))' [ Risks ] The proposed solution is minimally invasive. It changes precisely the code that currently raises an exception in a relatively obvious way. [ Checklist ] [x] *all* changes are documented in the d/changelog [x] I reviewed all changes and I approve them [x] attach debdiff against the package in (old)stable [x] the issue is verified as fixed in unstable [ Changes ] In older versions of python, it was possible to do: with (yield from somelock): ... That no longer works. The preferred method now is: async with somelock: ... However hbmqtt does not yet use the async/await syntax. So the contextmanager can be emulated: yield from somelock.acquire() try: .... finally: somelock.release While this is verbose, it works in all relevant Python versions. [ Upstreaming ] While the proposed fix has not been upstreamed, it has been reported upstream as https://github.com/beerfactory/hbmqtt/issues/223. The preferred solution there is switching to the async/await syntax. As such, upstreaming does not seem reasonable. [ Hats ] I am not a python-mqtt maintainer. I intend to NMU this fix. The issue was fixed in unstable using a NMU by me. Helmut
diff --minimal -Nru python-hbmqtt-0.9.6/debian/changelog python-hbmqtt-0.9.6/debian/changelog --- python-hbmqtt-0.9.6/debian/changelog 2020-12-04 23:52:25.000000000 +0100 +++ python-hbmqtt-0.9.6/debian/changelog 2021-12-13 15:16:34.000000000 +0100 @@ -1,3 +1,10 @@ +python-hbmqtt (0.9.6-1+deb11u1) bullseye; urgency=medium + + * Non-maintainer upload. + * Fix MQTTClient.connect. (Closes: #998912) + + -- Helmut Grohne <hel...@subdivi.de> Mon, 13 Dec 2021 15:16:34 +0100 + python-hbmqtt (0.9.6-1) unstable; urgency=low [ Debian Janitor ] diff --minimal -Nru python-hbmqtt-0.9.6/debian/patches/fix-connect.patch python-hbmqtt-0.9.6/debian/patches/fix-connect.patch --- python-hbmqtt-0.9.6/debian/patches/fix-connect.patch 1970-01-01 01:00:00.000000000 +0100 +++ python-hbmqtt-0.9.6/debian/patches/fix-connect.patch 2021-12-13 15:16:17.000000000 +0100 @@ -0,0 +1,15 @@ +--- a/hbmqtt/mqtt/protocol/handler.py ++++ b/hbmqtt/mqtt/protocol/handler.py +@@ -442,8 +442,11 @@ class ProtocolHandler: + @asyncio.coroutine + def _send_packet(self, packet): + try: +- with (yield from self._write_lock): ++ yield from self._write_lock.acquire() ++ try: + yield from packet.to_stream(self.writer) ++ finally: ++ self._write_lock.release() + if self._keepalive_task: + self._keepalive_task.cancel() + self._keepalive_task = self._loop.call_later(self.keepalive_timeout, self.handle_write_timeout) diff --minimal -Nru python-hbmqtt-0.9.6/debian/patches/series python-hbmqtt-0.9.6/debian/patches/series --- python-hbmqtt-0.9.6/debian/patches/series 2020-12-04 23:36:55.000000000 +0100 +++ python-hbmqtt-0.9.6/debian/patches/series 2021-12-13 15:16:02.000000000 +0100 @@ -1 +1,2 @@ 0001-Move-scripts-module-into-hbmqtt-module.patch +fix-connect.patch