Commit 66ebb5f8 authored by ZZH's avatar ZZH

opt 2026-6-25 15:57

parent 1a2725f7
...@@ -126,17 +126,12 @@ class Meter3rdForward: ...@@ -126,17 +126,12 @@ class Meter3rdForward:
async def snapshot_sampler(self): async def snapshot_sampler(self):
while not self.stop_event.is_set(): while not self.stop_event.is_set():
try: try:
# sec_to_min = 60 - (time.time() % 60) + 5 if self.d_last_msg:
# await asyncio.sleep(sec_to_min) cur_batch = dict(self.d_last_msg)
self.d_last_msg.clear()
if not self.d_last_msg: for fid, raw_msg in cur_batch.items():
continue if fid in SCADA_FIELDS_MAP:
await self.parse_and_forward(fid, raw_msg)
cur_batch = dict(self.d_last_msg)
self.d_last_msg.clear()
for fid, raw_msg in cur_batch.items():
if fid in SCADA_FIELDS_MAP:
await self.parse_and_forward(fid, raw_msg)
await asyncio.sleep(1) await asyncio.sleep(1)
except Exception as e: except Exception as e:
...@@ -216,4 +211,4 @@ if __name__ == '__main__': ...@@ -216,4 +211,4 @@ if __name__ == '__main__':
try: try:
asyncio.run(main()) asyncio.run(main())
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment