Browse Source

2022/11/08 修改接收状态消息超时时间

wk 2 years ago
parent
commit
a4c59444ef

File diff suppressed because it is too large
+ 48 - 637
入口单片机节点/message_pb2.py


+ 1 - 1
入口单片机节点/proto.sh

@@ -1 +1 @@
-protoc -I=../ message.proto --python_out=./ 
+protoc -I=../ message.proto --python_out=./

+ 1 - 1
指令检查节点/async_communication.py

@@ -88,7 +88,7 @@ class RabbitAsyncCommunicator(threading.Thread):
                     await message.ack()
                 if self._closing==True:
                     return
-    async def recv_statu(self,ex_name,key,ttl=1000):
+    async def recv_statu(self,ex_name,key,ttl=200):
         statu_ex=await self._channel_statu.get_exchange(ex_name)
         arg={}
         arg["x-message-ttl"]=ttl

+ 1 - 1
指令检查节点/proto.sh

@@ -1 +1 @@
-protoc -I=../ message.proto --python_out=./ 
+protoc -I=../ message.proto --python_out=./

+ 4 - 8
管理节点/async_communication.py

@@ -86,7 +86,7 @@ class RabbitAsyncCommunicator(threading.Thread):
                     await message.ack()
                 if self._closing==True:
                     return
-    async def recv_statu(self,ex_name,key,ttl=1000):
+    async def recv_statu(self,ex_name,key,ttl=200):
         statu_ex=await self._channel_statu.get_exchange(ex_name)
         arg={}
         arg["x-message-ttl"]=ttl
@@ -100,22 +100,18 @@ class RabbitAsyncCommunicator(threading.Thread):
                     return
 
     async def send(self):
-        ex_map={}
         while self._closing==False:
             if self._publish_msg_queue.qsize()>0:
                 try:
                     msg_bag = self._publish_msg_queue.get(False)
                     if not msg_bag == None:
                         ex_name, key, msg = msg_bag
-                        ex=ex_map.get(ex_name)
-                        if ex == None:
-                            ex = await self._channel_send.get_exchange(ex_name)
-                            ex_map[ex_name]=ex
+                        ex = await self._channel_send.get_exchange(ex_name)
                         await ex.publish(aio_pika.Message(body=msg.encode()), routing_key=key)
                 except:
                     await asyncio.sleep(1)
-            await asyncio.sleep(0)
-            time.sleep(0.001)
+            await asyncio.sleep(0.001)
+            #time.sleep(0.001)
 
 
     async def main(self):