From d47fbd65ab8197348ad293b7948fcdd2f8995594 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 31 八月 2023 13:16:00 +0800
Subject: [PATCH] L2数据上传任务守护线程

---
 test/test.py |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/test/test.py b/test/test.py
index 22daa71..705747f 100644
--- a/test/test.py
+++ b/test/test.py
@@ -1,4 +1,5 @@
 import multiprocessing
+import queue
 import threading
 import time
 
@@ -6,22 +7,32 @@
 from log_module import async_log_util
 from log_module.log import logger_debug
 
+__queue = queue.Queue()
+
 
 def read(pipe):
     while True:
-        val = pipe.recv()
-        if val:
-            print("read:", val)
+        if not __queue.empty():
+            val = __queue.get(block=False)
+            if val:
+                print("read:", val)
 
 
 def write(pipe):
     while True:
-        pipe.send("test")
+        __queue.put_nowait("123")
         time.sleep(1)
+        break
 
 
 if __name__ == "__main__":
     p1, p2 = multiprocessing.Pipe()
-    threading.Thread(target=lambda: write(p1), daemon=True).start()
+    t1 = threading.Thread(target=lambda: write(p1), daemon=True)
+    t1.start()
+    print("鏄惁alive锛�", t1.is_alive())
+
     threading.Thread(target=lambda: read(p2), daemon=True).start()
+    while True:
+        print("鏄惁alive锛�", t1.is_alive())
+        time.sleep(1)
     input()

--
Gitblit v1.8.0