Rocksolid Light

groups  faq  privacy  How to post  login

Message-ID:  

Q: What is the difference between Texas and yogurt? A: Yogurt has culture.


rocksolid / de.comp.lang.python / [Python-de] Re: paho-mqtt und vorgegebene Callback-Funktionen in einer Klasse.

SubjectAuthor
o [Python-de] Re: paho-mqtt und vorgegebene Callback-Funktionen in einer Klasse.Stefan Clauß

1
Subject: [Python-de] Re: paho-mqtt und vorgegebene Callback-Funktionen in einer Klasse.
From: Stefan Clauß
Newsgroups: de.comp.lang.python
Date: Wed, 21 Jun 2023 12:01 UTC
References: 1
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: st_cla...@gmx.de (Stefan Clauß)
Newsgroups: de.comp.lang.python
Subject: [Python-de]_Re:_paho-mqtt_und_vorgegebene_Callback-Funktionen_in_einer_Klasse.
Date: Wed, 21 Jun 2023 14:01:52 +0200
Lines: 82
Message-ID: <op.16v01ec0q0n66g@desktop-ekoajh9>
References: <u64v9c$2041$1@news1.tnib.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes
Content-Transfer-Encoding: Quoted-Printable
X-Trace: news.uni-berlin.de wKv/JykKiIVb+09gfc5hmg5EWW9duZUDW6vz5DmL3rBw==
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Opera Mail/1.0 (Win32)
Message-ID-Hash: 5SRVEXLQZGT4L6J7JKOJQ67SKIKKNJBE
X-Message-ID-Hash: 5SRVEXLQZGT4L6J7JKOJQ67SKIKKNJBE
X-MailFrom: gcpgg-python-de@m.gmane-mx.org
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-python-de.python.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
X-Mailman-Version: 3.3.9b1
Precedence: list
List-Id: Die Deutsche Python Mailingliste <python-de.python.org>
Archived-At: <https://mail.python.org/archives/list/python-de@python.org/message/5SRVEXLQZGT4L6J7JKOJQ67SKIKKNJBE/>
List-Archive: <https://mail.python.org/archives/list/python-de@python.org/>
List-Help: <mailto:python-de-request@python.org?subject=help>
List-Owner: <mailto:python-de-owner@python.org>
List-Post: <mailto:python-de@python.org>
List-Subscribe: <mailto:python-de-join@python.org>
List-Unsubscribe: <mailto:python-de-leave@python.org>
View all headers

Hallo,

versuche es mit self.on_connect und self.on_message jeweils auf der rechten
Seite der Zuweisung.

VG
Stefan

Am .06.2023, 19:12 Uhr, schrieb Marc Haber
<mh+usenetspam1118@zugschl.us>:

> Hallo,
>
> ich habe hier das abgespeckte, nicht lauffähige Teilprogramm:
>
> |#!/usr/bin/python
> |
> |import paho.mqtt.client as mqtt
> |
> |class ApplianceMonitor:
> | """the main ApplianceMonitor object"""
> |
> | def __init__(self):
> | # do something intelligent
> |
> | def on_connect(self, client, userdata, flags, rcode):
> | client.subscribe('tele/wama/SENSOR')
> |
> | def on_message(self, client, userdata, msg):
> | # do something intelligent with msg
> |
> | def main(self):
> | client = mqtt.Client()
> | client.on_connect = on_connect
> | client.on_message = on_message
> |
> | client.connect('mqtt.local', 1883, 60)
> |
> | client.loop_start()
> |
> | while True:
> | time.sleep(30)
> | # do something intelligent with the accumulated data
> |
> |
> |if __name__ == "__main__":
> | amon = ApplianceMonitor(args)
> | amon.main()
> |
> |# end of file
>
> Ich habe die ganze Applikation in eine Klasse ApplianceMonitor
> ausgelagert als Ergebnis der Diskussion von vor einem halben Jahr,
> weil ich so ohne globale Statusvariablen auskomme und die in der
> Klasse verstecken kann (hier nicht sichtbar weil sie der Minimierung
> des Codes zum Opfer gefallen sind).
>
> Leider haben die beiden Callbackfunktionen von paho eine vorgegebene
> Signatur und können deswegen keine Methoden des ApplianceMonitor sein.
> Wenn ich die Initialisierung des MQTT-Moduls ins Hauptprogramm
> verlagere, bin ich auf ein einziges Applikationsobjekt limitiert (was
> in der Tat blöd ist weil ich vielleicht später das Monitoring mehrerer
> MQTT-Topics mit mehreren Objekten des Applikationstyps machen möchte..
> Oder geht das sowieso nicht weil ich nur eine client.loop pro Programm
> haben kann?
>
> Ist das paho-Modul blöd oder ich? Oder geht das halt nicht anders?
>
> Grüße
> Marc

--
Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/


rocksolid / de.comp.lang.python / [Python-de] Re: paho-mqtt und vorgegebene Callback-Funktionen in einer Klasse.

1
server_pubkey.txt

rocksolid light 0.9.136
clearnet tor