import multiprocessing
|
import queue
|
import threading
|
import time
|
|
from huaxin_client import l2_data_manager
|
from log_module import async_log_util
|
from log_module.log import logger_debug
|
|
__queue = queue.Queue()
|
|
|
def read(pipe):
|
while True:
|
if not __queue.empty():
|
val = __queue.get(block=False)
|
if val:
|
print("read:", val)
|
|
|
def write(pipe):
|
while True:
|
__queue.put_nowait("123")
|
time.sleep(1)
|
break
|
|
|
if __name__ == "__main__":
|
p1, p2 = multiprocessing.Pipe()
|
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()
|