You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For package version paho-mqtt 1.5.1 and Python 3.8.2, running the following code:
frompaho.mqtt.clientimportClienttry:
Client(client_id="", clean_session=False)
exceptValueErrorase:
print(f"This is handled: {e}")
Produces the following output:
This is handled: A client id must be provided if clean session is False.
Exception ignored in: <function Client.__del__ at 0x7f4531fab0d0>
Traceback (most recent call last):
File "/c/Users/hibbe/Code/bg-hub-applications/.venv/lib/python3.8/site-packages/paho/mqtt/client.py", line 660, in __del__
self._reset_sockets()
File "/c/Users/hibbe/Code/bg-hub-applications/.venv/lib/python3.8/site-packages/paho/mqtt/client.py", line 704, in _reset_sockets
self._sock_close()
File "/c/Users/hibbe/Code/bg-hub-applications/.venv/lib/python3.8/site-packages/paho/mqtt/client.py", line 691, in _sock_close
if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
The error is raised in _sock_close when __del__ is called on the client as _sock_close checks if not self._sock: but the _sock attribute is never created on the client object as the exception is raised first (from __init__ of Client in .venv/lib/python3.8/site-packages/paho/mqtt/client.py):
ifnotclean_sessionand (client_id==""orclient_idisNone):
raiseValueError(
'A client id must be provided if clean session is False.')
self._clean_session=clean_sessioniftransport.lower() notin ('websockets', 'tcp'):
raiseValueError(
'transport must be "websockets" or "tcp", not %s'%transport)
self._transport=transport.lower()
self._protocol=protocolself._userdata=userdataself._sock=None
Perhaps either attribute initialisation should be moved earlier in the constructor, or _sock_close should check that the attribute exists.
The text was updated successfully, but these errors were encountered:
For package version paho-mqtt 1.5.1 and Python 3.8.2, running the following code:
Produces the following output:
The error is raised in
_sock_close
when__del__
is called on the client as _sock_close checksif not self._sock:
but the_sock
attribute is never created on the client object as the exception is raised first (from__init__
of Client in .venv/lib/python3.8/site-packages/paho/mqtt/client.py):Perhaps either attribute initialisation should be moved earlier in the constructor, or
_sock_close
should check that the attribute exists.The text was updated successfully, but these errors were encountered: