I am developing MQTT dashboard application with django. I have a table in database which contains list of devices, and one of its parameters is poll_interval_ms. I want to create MqttChannel object (class I created for mqtt connection with devices) for every device which has poll_interval greater than 0.
What I already learned is that any startup operations should be placed in ready method in class ApplicationConfig. So I am thinking about something like this:
class DashboardConfig(AppConfig):
name = 'dashboard'
client_list = []
def ready(self):
from .models import Device
devices_set = Device.objects.all()
for device in devices_set:
if device.poll_interval_ms > 0:
client = MqttChannel(device.id, is_server=True)
self.client_list.append(client)
Now my question is how to do it properly to access client_list later in code? Should I leave it as it is and access it as dashboard.apps.DashboardConfig.client_list (I'm not even sure if this will work) or is there some better way to do it?