Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Python Client inheritance

Hi guys,

I'm using the Python implementation of MQTT through the paho-mqtt package. The documentation says that you can inherit from the Client class to create your own MQTT_client. Nevertheless, inheriting from the client doesn't allow you to define some on_* functions directly in the class because they are overridden by the __init__ call of the base class...

So, there is any particular reason the define Client.on_* to None in the __init__ instead of using classical member functions like this :

class Client(object):
    def __init__(self, ...):
        ...
        # Nothing about self.on_*

    def on_*(self, ...):
        pass


An implementation like this would not break the actual behavior (you can redefine function, using mqttc.on_connect = my_new_connect_function), and it would be easier to inherit, defining overriding on_* functions in the sub-class.

If this seems a good idea, I propose myself to do the patch.

Kind regards,
Alexis BRENON

--
Doctorant sur le projet CASSIE (alexisbrenon.github.io)
Équipe GETALP (getalp.imag.fr)
Laboratoire d'Informatique de Grenoble (liglab.fr)



Back to the top