mirror of
https://github.com/NanjingForestryUniversity/supermachine-tobacco.git
synced 2025-11-08 22:33:54 +00:00
[fix] 修改过程
This commit is contained in:
parent
c6d544334c
commit
a42a2c023c
18
README.md
18
README.md
@ -461,3 +461,21 @@ def __setstate__(self, state):
|
||||
就是在序列化之前把不能序列化的stateful_things收起来,把`_stop_event`这个线程间同步用的东西也给收起来,然后就可以复制类内所有的变量新的独立的进程运行了,新的进程会拥有自己进程内独立的`_stop_event`,这就导致我们其实已经失去了对于这个新开辟的子进程的控制,除非它自己调用自己的self.stop。
|
||||
|
||||
好了,我觉得这个地方有点蠢,之后再改。
|
||||
|
||||
不对,经过我的实验,我发先函数在调用self.stop后依然生效,这太神奇了,不过我想了一下,还是因为主进程死了所以子进程也死了并不会有什么别的原因。
|
||||
|
||||
问题大的地方在于这里:
|
||||
|
||||
> 2022-08-23 15:49:57,770 - root - INFO - 测试子进程文件接收器
|
||||
> 2022-08-23 15:49:58,870 - root - INFO - Spent 59.68ms to get image with shape (1024, 4096, 3)
|
||||
> 2022-08-23 15:49:59,886 - root - INFO - Spent 56.07ms to get image with shape (1024, 4096, 3)
|
||||
> 2022-08-23 15:50:00,932 - root - INFO - Spent 84.52ms to get image with shape (1024, 4096, 3)
|
||||
> 2022-08-23 15:50:01,966 - root - INFO - Spent 97.37ms to get image with shape (1024, 4096, 3)
|
||||
> 2022-08-23 15:50:02,969 - root - INFO - Spent 78.12ms to get image with shape (1024, 4096, 3)
|
||||
|
||||
😮💨这个速度属实是拉胯,上网查了以后发现python的进程间通信(ipc)是个大问题,从2014年到2021年,关于这个队列慢的提问从来不停。
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import transmit
|
||||
from config import Config
|
||||
from transmit import FileReceiver, FifoReceiver, FifoSender
|
||||
from utils import ImgQueue
|
||||
from quick_queue.quick_queue import QQueue
|
||||
|
||||
|
||||
class TransmitterTest(unittest.TestCase):
|
||||
@ -33,7 +34,8 @@ class TransmitterTest(unittest.TestCase):
|
||||
def test_file_receiver_subprocess(self):
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
logging.info('测试子进程文件接收器')
|
||||
image_queue = multiprocessing.Queue()
|
||||
# image_queue = multiprocessing.Queue()
|
||||
image_queue = QQueue()
|
||||
file_receiver = FileReceiver(job_name='rgb img receive', input_dir='../data', output_queue=image_queue,
|
||||
speed=1, name_pattern=None, run_process=True)
|
||||
virtual_data = np.random.randint(0, 255, (1024, 4096, 3), dtype=np.uint8)
|
||||
@ -64,7 +66,6 @@ class TransmitterTest(unittest.TestCase):
|
||||
input_queue.put(virtual_data)
|
||||
logging.debug('put data to input queue done')
|
||||
virtual_data = image_queue.get()
|
||||
# logging.info(f'Spent {(current_time - time_record) * 1000:.2f}ms to get image with shape {virtual_data.shape}')
|
||||
self.assertEqual(virtual_data.shape, (1024, 4096, 3))
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user