Multi-process management framework system
By introducing a multi-process management framework system in software development, using the main control module, parameter control module, process management module and monitoring module, the problem of high difficulty in multi-process programming is solved, and efficient multi-process management and software development efficiency is achieved. promote.
Patent Information
- Application Number
- CN202411414290.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-02-14
AI Technical Summary
In existing software development, multi-process programming process management is difficult, and there is a lack of a simple and easy-to-use software framework, which leads to low software development efficiency and high difficulty in multi-process programming.
Provide a multi-process management framework system, including a main control module, a parameter control module, a process management module and a monitoring module. Through these modules, queues and events for inter-process communication are realized, multiple processes are started, exited and restarted, and information from subprocesses is transmitted to the user interface.
It effectively improves software development efficiency, reduces the difficulty of multi-process programming, and provides a simple and easy-to-use multi-process management framework.
Smart Images

Figure CN119440657A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of software development, and in particular relates to a multi-process management framework system. Background Art
[0002] In existing software development, the following problems are more prominent: in multi-task software, in order to improve the efficiency of concurrent multi-task execution, multi-process programming is required, but the process management of multi-process programming is more difficult, and there is no ready-made simple and easy-to-use software framework. Therefore, a multi-process management software architecture is urgently needed to improve software development efficiency and reduce the difficulty of multi-process programming. Summary of the invention
[0003] To this end, the present invention provides a multi-process management framework system to solve the problems of low software development efficiency and high difficulty of multi-process programming in existing software architectures.
[0004] To achieve the above objectives, the present invention adopts the following technical solutions:
[0005] In a first aspect, the present invention provides a multi-process management framework system, comprising:
[0006] Main control module, parameter control module, process management module and monitoring module;
[0007] The main control module is used to instantiate and load the parameter control module, the process management module and the monitoring module;
[0008] The parameter control module is used to convert the parameter information into a dictionary data storing the parameter information, and send the dictionary data to the main control module and the process management module;
[0009] The process management module is used to complete the opening, exiting and restarting of multiple processes through queues and events of inter-process communication;
[0010] The monitoring module is used to monitor the information of the sub-process and transmit the information to the user interface.
[0011] Furthermore, the opening, exiting and restarting of multiple processes are completed through queues and events of inter-process communication, including:
[0012] Create a process management class and use the first preset parameter as an input parameter of the class to complete the opening of multiple sub-processes; the first preset parameter is a parameter tuple, the number of creation queues, the number of creation events and a list of sub-process functions;
[0013] Controlling the subprocess to stop the task cycle and release the corresponding port through a preset process termination signal to complete the exit of the subprocess;
[0014] Restarting the multiple sub-processes is completed based on the opening and exiting of the multiple sub-processes.
[0015] Furthermore, the step of creating a process management class and using the first preset parameter as an input parameter of the class to start multiple sub-processes includes:
[0016] Using the first preset parameter as an input parameter of the process management class;
[0017] Creating multiple queues according to the number of created queues to obtain queue tuples;
[0018] Instantiate the process management class and obtain multiple events according to the number of created events to obtain an event tuple;
[0019] A plurality of the sub-processes are created according to the list of the sub-process functions; the parameters of the plurality of the sub-processes are the parameter tuple, the queue tuple and the event tuple.
[0020] Further, the preset process termination signal includes a first signal and a second signal; the controlling the subprocess to stop the task cycle and release the corresponding port through the preset process termination signal to complete the exit of the subprocess includes:
[0021] Calling a loop termination function according to the first signal to stop the task loop of the subprocess;
[0022] The interface release function is called according to the second signal to release the interface corresponding to the sub-process. Further, the restarting of the multiple sub-processes based on the opening and exiting of the multiple sub-processes includes:
[0023] Control the subprocess to stop the task cycle and release the corresponding port through a preset process termination signal;
[0024] Creating multiple queues according to the number of created queues to obtain queue tuples;
[0025] Instantiate the process management class and obtain multiple events according to the number of created events to obtain an event tuple;
[0026] A plurality of the sub-processes are created according to the list of the sub-process functions; the parameters of the plurality of the sub-processes are the parameter tuple, the queue tuple and the event tuple.
[0027] Furthermore, the parameter control module is based on the PySide6 library; the parameter information is converted into a dictionary data storing the parameter information, including:
[0028] The parameter information is converted into a dictionary storing the parameter information through the PySide6 library to complete the conversion between the dictionary and the local hard disk json file.
[0029] Furthermore, the monitoring module is based on Qwidget, Signal, QTimer in PySide6 and Queue in the multiprocessing library; the monitoring of the subprocess information includes:
[0030] Create a listening class and inherit Qwidget;
[0031] Instantiate a text signal Signal and a picture signal Signal inside the monitoring class with the monitoring parameter tuple as a parameter;
[0032] According to the order of the queues in the monitoring parameter tuple, the picture information queue and the text information queue that need to be monitored are obtained;
[0033] If the picture information queue is not empty, the picture information is obtained and sent through the picture signal Signal; if the text information queue is not empty, the text information is obtained and sent through the text signal Signal;
[0034] Instantiate Qtimer with the preset duration as a parameter and access the monitoring class.
[0035] Furthermore, the process management module is based on Python's own library multiprocessing.
[0036] Furthermore, it also includes:
[0037] The Signal instantiated in the listening module design and the information transmitted through the queue in the process management module are both tuples of length 2.
[0038] Furthermore, it also includes: developing a graphical user interface based on the PySide6 library.
[0039] The present invention adopts the above technical solution and has at least the following beneficial effects:
[0040] A multi-process management framework system is provided. The parameter control module, process management module and monitoring module are instantiated and loaded through the main control module. The parameter control module converts the parameter information into a dictionary data storing the parameter information, and sends the dictionary data to the main control module and the process management module. The process management module uses the queue and events of the inter-process communication to complete the opening, exiting and restarting of multiple processes. The monitoring module monitors the information of the sub-process and transmits the information to the user interface. Software development based on the main control module, parameter control module, process management module and monitoring module of the framework system can effectively improve the software development efficiency and reduce the difficulty of multi-process programming.
[0041] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 It is a schematic block diagram of a multi-process management framework system shown in an exemplary embodiment of the present invention.
[0044] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. DETAILED DESCRIPTION
[0045] In existing software development, the following problems are more prominent: in multi-tasking software, in order to improve the efficiency of concurrent multi-tasking execution, multi-process programming is required, but multi-process programming is more difficult, and there is no ready-made, simple and easy-to-use software framework. Therefore, a new software architecture is proposed to improve software development efficiency and reduce the difficulty of multi-process programming. The MVC architecture variants and extension modules of the prior art, such as MVVM (Model-View-ViewModel), focus on data binding and view state management, and MVP (Model-View-Presenter) strengthens the clear separation of view and business logic. They improve the flexibility and maintainability of software design in many aspects, but these existing architecture solutions and extension modules generally do not directly provide solutions to cross-process communication problems.
[0046] Inter-Process Communication (IPC) is a mechanism provided by the operating system to achieve data exchange and synchronization between different processes. Common IPC technologies include pipes, shared memory, message queues, sockets, and semaphores.
[0047] In this context, this software architecture proposes a unique process management module, uses Python to implement cross-process communication technology, effectively integrates the start, shutdown, and restart functions of multiple sub-processes, and defines a set of cross-process communication rules in this module.
[0048] This software architecture also proposes a communication monitoring module as another innovative extension of the MVC architecture. This module makes comprehensive use of Python's built-in multiprocessing library and the third-party library PySide6, allowing the main process to monitor and manage multiple sub-process information in real time, making up for the communication shortcomings of the traditional MVC architecture in a multi-process environment and ensuring the efficient operation and good collaboration of the entire system in a multi-process environment.
[0049] The framework system of the present invention is described below through specific embodiments.
[0050] See also Figure 1 , Figure 1 is a schematic block diagram of a multi-process management framework system shown in an exemplary embodiment of the present invention, see Figure 1 , the multi-process management framework system 100 includes:
[0051] The main control module 101 is used to instantiate and load the parameter control module, the process management module and the monitoring module;
[0052] The parameter control module 102 is used to convert the parameter information into a dictionary data storing the parameter information, and send the dictionary data to the main control module and the process management module;
[0053] The process management module 103 is used to complete the opening, exiting and restarting of multiple processes through queues and events of inter-process communication;
[0054] The monitoring module 104 is used to monitor the information of the child process and transmit the information to the user interface.
[0055] It should be noted that the technical solution provided in this embodiment can be loaded into an existing framework system in the form of a plug-in in specific practice, or in the form of a separate framework system. Applicable scenarios include but are not limited to: multi-process management and other application scenarios that require cross-communication process management.
[0056] It can be understood that the method provided in this embodiment instantiates and loads the parameter control module, the process management module and the monitoring module through the main control module, converts the parameter information into a dictionary data for storing the parameter information through the parameter control module, and sends the dictionary data to the main control module and the process management module at the same time, and uses the queues and events of inter-process communication through the process management module to complete the opening, exiting and restarting of multiple processes, and monitors the information of the sub-process through the monitoring module, and passes the information to the user interface; software development based on the main control module, parameter control module, process management module and monitoring module of this framework system can effectively improve software development efficiency and reduce the difficulty of multi-process programming.
[0057] In specific practice, the process management module completes the opening, exiting and restarting of multiple processes through queues and events of inter-process communication, including: creating a process management class and using the first preset parameter as the input parameter of the class to complete the opening of multiple sub-processes; the first preset parameter is a parameter tuple, the number of creation queues, the number of creation events and a list of sub-process functions; controlling the sub-process to stop the task loop and release the corresponding port through a preset process termination signal to complete the exit of the sub-process; and completing the restart of multiple sub-processes based on the opening and exit of multiple sub-processes.
[0058] It should be noted that the parameter tuple of the first preset parameter, the number of created queues, the number of created events and the list of sub-process functions can be set according to specific requirements; the process management module is based on Python's own library multiprocessing.
[0059] Specifically, a process management class is created and the first preset parameter is used as an input parameter of the class to complete the opening of multiple sub-processes, including: using the first preset parameter as an input parameter of the process management class; creating multiple queues according to the number of created queues to obtain queue tuples; instantiating the process management class and obtaining multiple events according to the number of created events to obtain event tuples; creating multiple sub-processes according to a list of sub-process functions; the parameters of the multiple sub-processes are parameter tuples, queue tuples and event tuples.
[0060] Specifically, the preset process termination signal includes a first signal and a second signal; the preset process termination signal is used to control the sub-process to stop the task loop and release the corresponding port to complete the exit of the sub-process, including: calling the loop termination function according to the first signal to stop the task loop of the sub-process; calling the interface release function according to the second signal to release the interface corresponding to the sub-process.
[0061] Specifically, the restart of multiple sub-processes is completed based on the opening and exit of multiple sub-processes, including: controlling the sub-process to stop the task loop and release the corresponding port through a preset process termination signal; creating multiple queues according to the number of created queues to obtain queue tuples; instantiating a process management class and obtaining multiple events according to the number of created events to obtain event tuples; creating multiple sub-processes according to a list of sub-process functions; the parameters of multiple sub-processes are parameter tuples, queue tuples and event tuples.
[0062] It can be understood that the technical solution provided in this embodiment can effectively improve software development efficiency and reduce the difficulty of multi-process programming by calling the process management module to use the queues and events of inter-process communication to complete the opening, exiting and restarting of multiple processes.
[0063] In specific practice, the parameter control module is based on the PySide6 library; the parameter information is converted into a dictionary data storing the parameter information, including: converting the parameter information into a dictionary storing the parameter information through the PySide6 library to complete the mutual conversion between the dictionary and the local hard disk json file.
[0064] In specific practice, the monitoring module is based on Qwidget, Signal, QTimer in PySide6 and Queue in the multiprocessing library; monitoring the information of the child process, including: creating a monitoring class and inheriting Qwidget; instantiating a text signal Signal and a picture signal Signal inside the monitoring class with the monitoring parameter tuple as a parameter; obtaining the picture information queue and text information queue that need to be monitored through the order of the queues in the monitoring parameter tuple; if the picture information queue is not empty, obtaining the picture information and sending it through the picture signal Signal; if the text information queue is not empty, obtaining the text information and sending it through the text signal Signal; instantiating Qtimer with the preset duration as a parameter and connecting to the monitoring class.
[0065] It should be noted that the preset duration may be 20, that is, monitoring is performed every 20 ms.
[0066] It should be noted that the Signal instantiated in the monitoring module design and the information transmitted through the queue in the process management module are both tuples of length 2.
[0067] In specific practice, it also includes: developing a graphical user interface based on the PySide6 library.
[0068] In a specific embodiment, the process management module uses Manager, Process, and Queue of the multiprocessing library to construct a multi-process start mechanism, exit mechanism, and restart mechanism.
[0069] Loading process management module and multi-process opening mechanism:
[0070] Step 1: Construct a class called AI_Manager, passing in parameters such as the parameter tuple, the number of queues to be created, the number of events to be created, and a list of subprocess functions.
[0071] Step 2: Create n queues according to the parameter (the number of queues created n), store them in a tuple, and use them for external module calls. When making external calls, specify the usage in order, such as the first queue is used for the receiving interface of subprocess 1, and the second queue is used for the receiving interface of subprocess 2. This tuple can be used for the unified calling interface of other modules or subprocesses, and different processes can take out the corresponding queues in order for use.
[0072] Step 3: Instantiate Manager, and create n Events through Manager according to the parameters (the number of events to be created n), and store them in a tuple, which can be used for external module calls. When making external calls, specify the usage in order. This tuple can be used for a unified calling interface of other modules or subprocesses, such as: the start parameters of multiple subprocesses are all event_tuple, and within a test subprocess, the required test_event is obtained through the predetermined order in the tuple. Among the n Events, the first three are default values (check_once_event, close_event, cap_release_event), which are used to detect one-time events, process closing events, and port release events, respectively. Among them, the set() method is executed when cap_release_enevt is created, indicating that the port has been released.
[0073] Step 4: Create multiple processes. According to the parameters (list of subprocess functions), create multiple subprocesses. The parameters of the subprocesses are unified as the Queue tuple in step 2, the Event tuple in step 3, and the parameters (set parameter tuple).
[0074] The above completes the loading of the process management module and the opening of multiple processes.
[0075] Multi-process exit mechanism: To ensure that the child process exits safely and releases the port successfully, the following requirements are made:
[0076] Requirement 1: When an Event is created, there are two necessary event signals: the close_event event responsible for closing the subprocess task loop and the cap_release_event event responsible for ensuring that the port has been released. Example: The subprocess task loop uses "while not close_event.is_set()" as the start condition. When the close_event.set() method is called, the task loop exits. cap_release_event is set to the set state when it is created. When a subprocess uses a device that occupies a port, the subprocess calls the cap_release_event.clear() method after opening the port. When the subprocess receives the exit signal to terminate the while loop, it first executes the port release operation and then executes the cap_release_event.set() method.
[0077] Requirement 2: After the child process enters the task loop, it first receives the information in the communication queue and determines whether it is information requesting to terminate the loop. If so, it executes break to exit the loop.
[0078] Requirement 3: If the child process is in the same task loop, there may be tasks of receiving and sending information at the same time. Before using the get method to receive communication queue information, first determine whether the communication queue is not empty. If it is not empty, then obtain the information.
[0079] Requirement 4: When a child process uses the Queue.put method to send information to the queue of another process, if it is known that the queue will receive a large number of messages, first use the queue.full() method to determine whether the queue is not full. If it is not full, send information to it, otherwise skip it. For example: The camera image acquisition child process sends information to the queue displayed on the interface. Since the child process acquires images faster than the main process display speed, the queue displayed on the interface is full.
[0080] When the above requirements are met, perform the following exit steps:
[0081] Step 1: Execute the close_event.set() method and call queue_tuple to traverse each queue and use the queue.full() method to determine whether the queue is not full. If it is not full, send a command with the semantics of "terminate loop" to it and terminate the loop according to the principle in requirement 2.
[0082] Step 2: Execute the close_event.wait() method to wait for the first step set method command to take effect, refer to the principle in requirement 1, and terminate the loop.
[0083] Step 3: Use cap_release_event.wait() method to wait for the release of the port in the child process.
[0084] Step 4: Traverse each child process in terminate_process_list to determine whether the child process is alive. If so, execute the terminate() destruction method.
[0085] Step 5: Call the Manager's shutdown() method to shut down the Manager.
[0086] The above completes the safe exit of all subprocesses.
[0087] Multi-process restart mechanism:
[0088] Step 1: Execute steps 1 to 5 in the multi-process exit mechanism.
[0089] Step 2: Execute steps 2, 3, and 4 in the multi-process opening mechanism.
[0090] The above completes the restart of multiple processes.
[0091] In a specific embodiment, the parameter control module creates a PySide6 class with the following methods:
[0092] Method 1: Get the setting parameters from the interface: Collect the values of each component on the setting interface and generate a dictionary A. Dictionary A can be a composite dictionary, that is, the key of dictionary A is mapped to another dictionary. The format is as follows: {"Camera 1":{"Camera serial number":"None","Width":1280,"Height":720},"Camera 2":{"Camera serial number":"None","Width":1280,"Height":720}. Store dictionary A in the attribute dict_setup_tuple of the class. The attribute is a tuple, and the elements in the tuple are dictionary A. If there are other parameter control modules, generate a new dictionary B. The format of the tuple is as follows: (Dictionary A, Dictionary B). Other modules can access the dictionary in the tuple by accessing the attribute dict_setup_tuple and the predicted element order, that is, obtain the setting information.
[0093] Method 2 implements the saving and loading of setting parameters: This module operates the dictionary in the attribute dict_setup_tuple through Python's IO library and json library to complete the conversion between the .json file on the hard disk and the dictionary dict in the memory.
[0094] Method 3 implements the operation of the subprocess through the interface setting: by calling the handle reserved by the process management module, the change request of a specific parameter of the setting interface and the changed parameter dictionary are sent to the communication queue of the corresponding subprocess.
[0095] In a specific embodiment, the monitoring module: The design of this module uses QWidget, Signal, QTimer in PySide6 and Queue in the multiprocessing library. The implementation steps are as follows:
[0096] Step 1: Create a class that inherits QWidget and instantiate two signals Signal internally. The parameters are tuples, indicating that the information sent by Signal is a tuple. send_txt_signal, which sends text signals, and send_img_signal, which sends image signals, need to monitor only two types of information, namely text information and image information. The sending parameter is a tuple. For example, when sending the text message "break", the tuple is ("break", "break").
[0097] Step 2: Load the queue_tuple of the process management module, and obtain the queues for monitoring image information and text information through the known order of queues in the tuple.
[0098] Step 3: Create a monitoring method: Determine whether the queue of image information is empty. If not, call the queue.get method to obtain the image information, and send it through the send_img_signal instantiated in step 1, and call the Signal.emit method. Determine whether the queue of text information is empty. If not, call the queue.get method to obtain the text information, and send it through the send_txt_signal instantiated in step 1.
[0099] Step 4: Instantiate QTimer and connect the timeout signal of QTimer to the listening method created in step 3.
[0100] Step 5: Start the QTimer instantiated in step 4 with a parameter of 20, which means monitoring once every 20ms.
[0101] In a specific embodiment, information structure: the information circulated in the entire software architecture conforms to the same specification. The information is a tuple with a length of 2 and a structure of ("flag bit", "specific content"). The Signal instantiated in the design of the monitoring module and the information transmitted through the queue in the process management module all conform to the specification. In the decoding module after the main control module or the subprocess receives the information, the decoding is performed in the following steps:
[0102] Step 1: Get the information tuple
[0103] Step 2: The first information of the tuple is the flag bit. Determine whether the value of the flag bit is in the preset decoding list. If so, perform the flag bit value mapping action.
[0104] In a specific embodiment, the main control module inherits from the class in PySide6 and performs the following steps:
[0105] Step 1: Instantiate and load the parameter control module. There can be multiple parameter control modules.
[0106] Step 2: Instantiate and load the process management module, and add the handle of the process management module to the parameter control module.
[0107] Step 3: Instantiate and load the monitoring module, and add the queue_tuple handle of the process management module to the monitoring module.
[0108] Step 4: Instantiate and load other display interface components, and modify the interface according to the newly designed UI interface.
[0109] Step 5: Create a decoding method for tuple information, and make a mapping relationship based on the predicted unified tuple information flags. Each flag corresponds to a function method that is preset on demand.
[0110] Step 6: Connect the monitoring signal of the monitoring module to the decoding method created in step 5. Connect the interface components (buttons) and other functions with the main control module.
[0111] In a specific embodiment, the framework structure of the subprocess has the following design:
[0112] Design 1: The subprocess is a function. The parameters of the function have been mentioned above, which are three tuples in the process management module: event_tuple, queue_tuple, and dict_setup_tuple. Different subprocesses share the same parameters. The parameters required by different subprocesses are obtained by predicting the order of elements in the tuple.
[0113] Design 2: Use "while not close_event.is_set()" as the task loop start condition.
[0114] Design 3: Receive information through the queue, create decoding conditions for the information, and if the flag bit of the information meets the requirements, perform a specific action, such as exiting the loop.
[0115] Design 4: After starting the task loop, use the get method to receive the communication queue information. If the subprocess task loop can be summarized as the following mode: wait for information, receive information, process information, return results, continue to wait for information, and the waiting time is a certain period of time, then do not determine whether the communication queue is not empty, directly use the get method to obtain information, and use the Queue queue to use the get() method when there is no information, which will block and wait. Use the while loop to pause and save CPU resources.
[0116] Design 5: Meet the requirements of the multi-process exit mechanism in the process management module for the use of Event.
[0117] Design 6: The subprocess as a whole is a function. The operation of importing the module needs to be written inside the function to increase the speed of starting the process.
[0118] Design 7: Among many sub-processes, there is a sub-process that is responsible for the main detection task. When the detection is turned on, for example, in the task loop, the test event test_event is turned on, and the test_event.is_set() method is called to return TRUE, then a thread is created to execute the main detection task. After the task is completed, the test_event.clear() method is called inside the thread to reset the event.
[0119] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0120] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0121] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0122] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0123] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0124] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A multi-process management framework system, characterized in that: include: Main control module, parameter control module, process management module and monitoring module; The main control module is used to instantiate and load the parameter control module, the process management module and the monitoring module; The parameter control module is used to convert the parameter information into a dictionary data storing the parameter information, and send the dictionary data to the main control module and the process management module; The process management module is used to complete the opening, exiting and restarting of multiple processes through queues and events of inter-process communication; The monitoring module is used to monitor the information of the sub-process and transmit the information to the user interface.
2. The frame system according to claim 1, characterized in that: The process of starting, exiting and restarting multiple processes through queues and events of inter-process communication includes: Create a process management class and use the first preset parameter as an input parameter of the class to complete the opening of multiple sub-processes; the first preset parameter is a parameter tuple, the number of creation queues, the number of creation events and a list of sub-process functions; Controlling the subprocess to stop the task cycle and release the corresponding port through a preset process termination signal to complete the exit of the subprocess; Restarting the multiple sub-processes is completed based on the opening and exiting of the multiple sub-processes.
3. The frame system according to claim 2, characterized in that: The step of creating a process management class and using the first preset parameter as an input parameter of the class to complete the opening of multiple sub-processes includes: Using the first preset parameter as an input parameter of the process management class; Creating multiple queues according to the number of created queues to obtain queue tuples; Instantiate the process management class and obtain multiple events according to the number of created events to obtain an event tuple; A plurality of the sub-processes are created according to the list of the sub-process functions; the parameters of the plurality of the sub-processes are the parameter tuple, the queue tuple and the event tuple.
4. The frame system according to claim 3, characterized in that: The preset process termination signal includes a first signal and a second signal; the controlling the sub-process to stop the task cycle and release the corresponding port through the preset process termination signal to complete the exit of the sub-process includes: Calling a loop termination function according to the first signal to stop the task loop of the subprocess; An interface release function is called according to the second signal to release the interface corresponding to the child process.
5. The frame system according to claim 4, characterized in that: The restarting of the plurality of sub-processes based on the opening and exiting of the plurality of sub-processes includes: Control the subprocess to stop the task cycle and release the corresponding port through a preset process termination signal; Creating multiple queues according to the number of created queues to obtain queue tuples; Instantiate the process management class and obtain multiple events according to the number of created events to obtain an event tuple; A plurality of the sub-processes are created according to the list of the sub-process functions; the parameters of the plurality of the sub-processes are the parameter tuple, the queue tuple and the event tuple.
6. The frame system according to claim 1, characterized in that: The parameter control module is based on the PySide6 library; The step of converting the parameter information into a dictionary data storing the parameter information includes: The parameter information is converted into a dictionary storing the parameter information through the PySide6 library to complete the conversion between the dictionary and the local hard disk json file.
7. The frame system according to claim 1, characterized in that: The monitoring module is based on Qwidget, Signal, QTimer in PySide6 and Queue in the multiprocessing library; the information of the subprocess monitored includes: Create a listening class and inherit Qwidget; Instantiate a text signal Signal and a picture signal Signal inside the monitoring class with the monitoring parameter tuple as a parameter; According to the order of the queues in the monitoring parameter tuple, the picture information queue and the text information queue that need to be monitored are obtained; If the picture information queue is not empty, the picture information is obtained and sent through the picture signal Signal; if the text information queue is not empty, the text information is obtained and sent through the text signal Signal; Instantiate Qtimer with the preset duration as a parameter and access the monitoring class.
8. The frame system according to claim 1, characterized in that: The process management module is based on Python's own library multiprocessing.
9. The frame system according to claim 1, characterized in that: Also includes: The Signal instantiated in the listening module design and the information transmitted through the queue in the process management module are both tuples of length 2.
10. The frame system according to claim 1, characterized in that: Also includes: Graphical user interface development is implemented based on the PySide6 library.