:art: close_old_connections()

huangqimin001 3 ans auparavant
Parent
Commettre
fca0a4e1aa
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 3 1
      commands/management/commands/mqtt.py

+ 3 - 1
commands/management/commands/mqtt.py

@@ -4,7 +4,7 @@ import logging
4 4
 import random
5 5
 import time
6 6
 
7
-from django_six import CompatibilityBaseCommand
7
+from django_six import CompatibilityBaseCommand, close_old_connections
8 8
 from paho.mqtt import client as mqtt_client
9 9
 
10 10
 from api.eqpt_views import mqtt_upload_temperature
@@ -87,7 +87,9 @@ def subscribe(client: mqtt_client):
87 87
         # }
88 88
         payload = msg.payload.decode()
89 89
         print(f'Received `{payload}` from `{msg.topic}` topic')
90
+        close_old_connections()
90 91
         mqtt_upload_temperature(payload)
92
+        close_old_connections()
91 93
 
92 94
     client.subscribe(topic)
93 95
     client.on_message = on_message