Administrator
2023-09-18 0ced5496fcfcb9de9927793023e8692fe792b477
test/test.py
@@ -1,22 +1,39 @@
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 start_thread():
    print(threading.current_thread().getName(), threading.current_thread().ident)
def add_data(msg):
    time.sleep(1)
    start_time = time.time()
    __queue.put({"msg": msg})
    end_time = time.time()
    if end_time - start_time > 0.002:
        print("加入日志耗时")
def test_process_1(pipe):
    while True:
        for i in range(10):
            pipe.send_bytes(f"hello world:{i}".encode("utf-8"))
            time.sleep(1)
def test_process_2(pipe):
    while True:
        results = pipe.recv_bytes()
        if results:
            print("接受到内容:", results)
if __name__ == "__main__":
    _queue = queue.Queue()
    _queue.put("123123")
    print(_queue.get(False))
    print(_queue.get(False))
    p1, p2 = multiprocessing.Pipe()
    # L1订阅数据
    progress1 = multiprocessing.Process(target=lambda: test_process_1(p1))
    progress2 = multiprocessing.Process(target=lambda: test_process_2(p2))
    progress1.start()
    progress2.start()
    input()