Task processing method and device, electronic equipment and storage medium

By introducing two-level thread pools, fast pool and slow pool, into the task flow system, the problem of low task processing speed is solved, efficient processing and resource utilization of the task flow system is achieved, and task waiting time is reduced.

CN118733218APending Publication Date: 2024-10-01BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410751072.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The existing task flow system cannot effectively utilize efficient thread resources when processing tasks, resulting in low task processing speed and inability to switch threads in time when tasks are abnormal, affecting the overall system performance.

Method used

By introducing two-level thread pools into the task flow system, fast pool (fast pool) and slow pool (slow pool), when receiving a task processing request, the first thread with faster processing speed will be used first to process the task; when the task is in In an abnormal state, the first thread is stopped and switched to the second thread with a slower processing speed to continue processing to ensure the continuity and efficiency of the task flow.

Benefits of technology

It improves the overall processing speed of the task flow system, releases efficient thread resources to the next task flow, reduces the waiting time for new tasks, balances the processing peaks and troughs of the thread pool, and improves the system's task flow processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733218A_ABST
    Figure CN118733218A_ABST
Patent Text Reader

Abstract

The invention provides a task processing method and device, electronic equipment and a storage medium, and relates to the technical field of computers, in particular to the field of cloud services and the field of task scheduling. According to the specific implementation scheme, in response to a processing request for a target task flow, a first thread is scheduled to arrange a first task from the target task flow to start processing tasks in the target task flow; when a first task in the target task flow is in an abnormal processing state, stopping the first thread from processing the tasks in the target task flow, and scheduling a second thread to continuously process the tasks in the target task flow from the first task; wherein the processing speed of the first thread is greater than that of the second thread.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, in particular to the field of cloud services and task scheduling. The present disclosure specifically relates to a task processing method, device, electronic device and storage medium. Background Art

[0002] The current common task flow systems are generally centralized task flow systems and distributed task flow systems. Among them, the centralized task flow system relies on centralized nodes and schedules various business programs through API interfaces to complete various tasks in the task flow. The distributed task flow system packages each task in the task flow into a code package and distributes it to each execution node. Each execution node executes the code in the task code package to complete the task. Summary of the invention

[0003] The present disclosure provides a task processing method, device, electronic device and storage medium.

[0004] According to one aspect of the present disclosure, there is provided a task processing method, comprising:

[0005] In response to a processing request for a target task flow, scheduling a first thread to process tasks in the target task flow starting from the task that is first arranged in the target task flow;

[0006] When the first task in the target task flow is in a processing exception state, stop the first thread from processing the tasks in the target task flow, and schedule the second thread to continue processing the tasks in the target task flow starting from the first task;

[0007] The processing speed of the first thread is greater than the processing speed of the second thread.

[0008] According to another aspect of the present disclosure, there is provided a task processing device, comprising:

[0009] A first task processing module, configured to, in response to a processing request for a target task flow, schedule a first thread to process tasks in the target task flow starting from the task that is first arranged in the target task flow;

[0010] A second task processing module is used to stop the first thread from processing the tasks in the target task flow when the first task in the target task flow is in a processing exception state, and schedule the second thread to continue processing the tasks in the target task flow starting from the first task;

[0011] The processing speed of the first thread is greater than the processing speed of the second thread.

[0012] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0013] at least one central processing unit; and

[0014] A memory in communication with the at least one central processing unit; wherein,

[0015] The memory stores instructions that can be executed by the at least one central processing unit, and the instructions are executed by the at least one central processing unit so that the at least one central processing unit can execute any task processing method in the embodiments of the present disclosure.

[0016] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any task processing method in the embodiments of the present disclosure.

[0017] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements any task processing method according to the embodiments of the present disclosure when executed by a processor.

[0018] According to the technology disclosed in the present invention, in response to a processing request for a target task flow, a first thread with a faster processing speed is scheduled to process tasks in the target task flow starting from the first task in the target task flow; when the first task in the target task flow is in an abnormal processing state, the first thread is stopped from processing tasks in the target task flow, and a second thread with a slower processing speed than the first thread is scheduled to continue processing tasks in the target task flow starting from the first task. In this way, the overall speed of task flow system processing tasks can be improved, and this can also release the first thread with a faster processing speed to the next triggered task flow, reducing the waiting processing time of the newly triggered task.

[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0021] Figure 1 is a flowchart of a task processing method according to an embodiment of the present disclosure;

[0022] Figure 2 is a flowchart of a task processing method according to another embodiment of the present disclosure;

[0023] Figure 3 is a structural block diagram of a task flow component according to an embodiment of the present disclosure;

[0024] Figure 4 is a schematic diagram of a task flow type according to an embodiment of the present disclosure;

[0025] Figure 5 is a structural block diagram of a task flow processing device according to an embodiment of the present disclosure;

[0026] Figure 6 is a structural block diagram of a task flow processing device according to another embodiment of the present disclosure;

[0027] Figure 7 is a block diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0029] In order to facilitate understanding of the trajectory planning method provided by the embodiment of the present disclosure, the related technologies of the embodiment of the present disclosure are explained below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiment of the present disclosure as optional solutions, and they all belong to the protection scope of the embodiment of the present disclosure.

[0030] Figure 1 : is a flowchart of a task processing method of an embodiment of the present disclosure. The method can be applied to an electronic device. The electronic device is, for example, a terminal, a server or other processing device, wherein the terminal can be a user equipment (UE) such as a desktop computer, a mobile device, a PDA (Personal Digital Assistant), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some implementations, the electronic device can implement the task processing method of an embodiment of the present disclosure by calling a computer-readable instruction stored in a memory by a central processing unit.

[0031] like Figure 1 As shown, the method may include the following steps:

[0032] S110, in response to a processing request for a target task flow, scheduling a first thread to process tasks in the target task flow starting from the task that is first arranged in the target task flow;

[0033] S120, when the first task in the target task flow is in a processing exception state, stop the first thread from processing the tasks in the target task flow, and schedule the second thread to continue processing the tasks in the target task flow starting from the first task.

[0034] The processing speed of the first thread is greater than the processing speed of the second thread.

[0035] It can be understood that the target task flow may include one or more tasks. Alternatively, the task is actually a task flow, and the target task flow and the tasks included therein form a parent task flow and a child task flow relationship.

[0036] Understandably, the above processing request for the target task flow may be a first processing request. That is, each task in the task flow has not been processed. If some tasks in the task flow have been executed (or processed), when the task flow is processed again, the second thread is used to continue processing the tasks in the target task flow starting from the task that ranks first among the unprocessed tasks in the target task flow.

[0037] It can be understood that in response to a processing request for a target task flow, a first thread in an idle state is determined from the first thread pool, and the first thread is scheduled to process tasks in the target task flow starting from the first task in the target task flow.

[0038] It can be understood that when the first task in the target task flow is in a processing exception state, a second thread in an idle state is determined from the second thread pool, and the second thread is scheduled to continue processing the tasks in the target task flow starting from the first task.

[0039] It can be understood that the maximum number of parallel execution threads of the first thread pool is greater than the maximum number of parallel execution threads of the second thread pool. Thus, the speed of task flows processed by the first thread pool is generally better than the speed of task flows processed by the second thread pool.

[0040] It can be understood that the first task may be a task flow, which may include one or more subtasks.

[0041] It can be understood that the database includes the input parameter data, output data and operation status of each task in each task flow. It can be understood that for any task flow, it has a corresponding state machine in the database for recording the operation status of the task flow and the operation status of each task in the task flow. The operation state can include an initialization state, a processing state (being executed), a suspended processing state (suspended execution state), a pending processing state (pending execution state), a processing success state (execution success state), a processing failure state (execution failure state), a cancellation processing state (cancellation execution state), an abnormal processing state (execution abnormal state) and an unprocessed state (unexecuted state), etc.

[0042] For example, Figure 2 As shown, when a thread starts processing a task, its execution process or execution state includes the following:

[0043] Initialize the task. Record the task as being in an initialization state in a task flow table in the task database. For example, Init is used to represent the state. The task flow table includes the states of multiple task flows and the states of tasks in each task flow.

[0044] The initialized task is processed or executed. In the task flow table in the task database, the task is recorded as being in a processing state, for example, Processing is used to represent the state.

[0045] If the task is a task flow, and the last task (Task) in the task flow returns successful processing (Succeed), the operation status of the task flow is recorded as a successful processing status, which can be represented by Succeed; if it returns to cancel execution, the operation status of the task flow is recorded as a cancel execution status, which can be represented by Canceled.

[0046] If the task is a task, the task is processed successfully and the task is recorded as being in a processed successfully state; if the task is cancelled, the task is recorded as being in a cancelled state.

[0047] If the task fails to be processed, the operation status of the task is recorded as a failed status, for example, Failed. The failed task can be re-executed to enter the processing status.

[0048] If the task is suspended, its status is recorded as a suspended status, for example, Paused is used to represent it.

[0049] The suspended task can be resumed and put into the pending state, i.e. Pending. Then, the task in the pending state is re-executed and put into the processing state. The task or task flow in the processing state can be put into the pending state if it is retried next time.

[0050] It can be understood that the processing abnormal state may include being in the initialization state or the processing state for too long. Alternatively, the processing abnormal state may include an execution failure state.

[0051] It can be understood that the operation status of each task in the target task flow can be determined by querying or viewing the state machine of the target task flow in the database using the identity of the target task flow. If the operation status of the first task currently executed for the target task flow is a processing exception state, a second thread in an idle state is determined from the second thread pool, and the second thread is scheduled to continue processing the tasks in the target task flow starting from the first task.

[0052] It can be understood that the first thread pool is a thread pool with a faster processing speed, which can also be called a fast pool. The second thread pool is a thread pool with a slower processing speed, which can also be called a slow pool. The first thread pool includes one or more threads. The second thread pool includes one or more threads. These threads can execute tasks or task flows in parallel.

[0053] According to the above implementation, in response to a processing request for a target task flow, a first thread with a faster processing speed is scheduled to process tasks in the target task flow starting from the first task in the target task flow; when the first task in the target task flow is in an abnormal processing state, the first thread is stopped from processing tasks in the target task flow, and a second thread with a slower processing speed than the first thread is scheduled to continue processing tasks in the target task flow starting from the first task. In this way, the overall speed of task flow system processing tasks can be improved, and this can also release the first thread with a faster processing speed to the next triggered task flow, reducing the waiting processing time of the newly triggered task.

[0054] In one embodiment, the first thread is located in a first thread pool, the second thread is located in a second thread pool, the first thread pool includes multiple threads, the second thread pool includes multiple threads, and the maximum number of parallel execution threads in the first thread pool is greater than the maximum number of parallel execution threads in the second thread pool.

[0055] Exemplarily, the processing speed of any thread in the first thread pool may be greater than the processing speed of any thread in the second thread pool.

[0056] Exemplarily, if the operation status of each task in the target task flow is an unprocessed status, a first thread in an idle status may be scheduled from the first thread pool to execute each task in the target task flow.

[0057] Exemplarily, if there is a task in the target task flow whose operation status is in the executed state, a second thread in an idle state is scheduled from the second thread pool to execute unprocessed tasks in the target task flow.

[0058] Exemplarily, if the first thread is executing the first task in the target task flow, and the operation state of the first task is an exception handling state, the first thread no longer executes the target task flow, and the first thread enters an idle state. At the same time, the second thread in the idle state is scheduled from the second thread pool to execute the unprocessed tasks in the target task flow starting from the first task.

[0059] For example, for a newly triggered task flow, the thread in the fast pool is used to execute the task flow. When a task in the task flow is in an abnormal state such as a failed state or a retry waiting state, the task flow is dispatched to the thread in the slow pool for processing. In this way, the gap between the processing peaks and troughs of the fast pool can be smoothed, so that the fast pool can have more idle threads to provide for new task flows to use, which can improve the system's task flow processing efficiency.

[0060] It should be noted that a task flow is a collection of multiple tasks. The tasks in the collection can be executed in the fast pool or the slow pool at a time, but cannot be executed in both the fast pool and the slow pool at the same time.

[0061] According to the above implementation, each thread in the first thread pool with a larger maximum number of parallel execution threads is used to process the task flow of the first request processing. When the task currently executed in the task flow enters an abnormal state, the task flow is dispatched from the first thread pool to the second thread pool with a smaller maximum number of parallel execution threads for execution. Since the number of parallel execution threads in the first thread pool is large, the speed of processing the task flow will be higher than that of the second thread pool with a smaller number of parallel execution threads. In this way, when the task processed by the first thread is abnormal, the first thread in the first thread pool can be released to the task flow of the next request, smoothing the processing peak of the first thread pool and avoiding the next task flow waiting for processing for too long.

[0062] In one embodiment, the above method may also include: in response to a pause processing instruction for the target task flow, in the task database, setting the target state of the target task flow in the first task flow state change table to a pause processing state; based on the updated first task flow state change table, updating the second task flow state change table in the cache, so that the target state of the target task flow in the second task flow state change table is set to a pause processing state; wherein the second task flow state change table is used for the first thread to query the target state of the target task flow in the cache when the adjacent second task in the target task flow is in a processed state and the third task is in an unprocessed state, wherein the execution order of the second task is greater than the execution order of the third task; and the first thread is used to stop processing the tasks in the target task flow when it is found in the cache that the target state of the target task flow is a pause processing state.

[0063] It is understandable that the pause processing instruction may come from a user or other external device, such as a robot. Alternatively, the pause processing instruction may be automatically generated within the system at a fixed time interval.

[0064] It can be understood that the processed state may include a successfully processed state, a failed processed state, a suspended processing state, a waiting processing state, etc. The unprocessed state refers to a state in which the task has not been processed.

[0065] It can be understood that each thread in the system can query the second task flow state change table in the cache.

[0066] It can be understood that the first task flow state change table includes the target state of each task flow. The target state is the state that the task flow is about to be in.

[0067] It can be understood that the second task flow state change table includes the target state of each task flow. The first task flow state change table is located in the database, and the second task flow state change table is located in the cache.

[0068] It can be understood that the first task and the second task mentioned above may be the same task or may not be the same task.

[0069] Exemplarily, the second task flow state change table in the cache may be synchronously updated based on the first task flow state change table in the task database at a fixed time interval. Alternatively, whenever the first task flow state change table is updated, the second task flow state change table in the cache may be synchronously updated based on the updated first task flow state change table.

[0070] In actual applications, when a task in a task flow is being processed in a thread, sending a pause processing instruction or a stop processing instruction to the task flow cannot prevent the execution of the tasks in the task flow. It is necessary to wait for the currently executing task in the task flow to be completed before the thread can stop executing the task flow.

[0071] In this example, the target state of the target task flow in the first task flow state change table is modified to a pause processing instruction, which can have the effect of issuing a stop execution instruction for the target task flow to the first thread.

[0072] In this example, the operation state of the target task flow in the first task flow state change table in the database is changed, and the first task flow state change table is synchronized to the cache to obtain the second task flow state change table. When the second task currently being processed in the first thread has been processed and is ready to process the next task, i.e., the third task, the first thread can query the target state of the target task flow in the second task flow state change table in the cache. If the target state of the target task flow is a suspended processing state, the first thread stops processing the target task flow, thereby achieving the effect of task flow interception.

[0073] In some embodiments, the suspended task flow can also be restarted. For example, in response to a restart instruction for the target task flow, the target state of the target task flow in the first task flow state change table is deleted, or updated from the suspended processing state to the processing state; based on the updated first task flow state change table, the second task flow state change table in the cache is updated to delete the target state of the target task flow in the second task flow state change table, or update from the suspended processing state to the processing state.

[0074] Exemplarily, the preset time may be 10 seconds, 30 seconds, or one minute, etc.

[0075] Exemplarily, at a preset time interval, based on the first task flow state change table in the database, the second task flow state change table in the cache is synchronously updated.

[0076] According to the above implementation, when a task flow is suspended, if a restart instruction is received, since the task flow was previously suspended, its target state in the first task flow state change table and the second task flow state change table is still a suspended processing state. At this time, it is necessary to delete the target state or update it to a processing state so that the target task flow is not prevented from continuing to execute.

[0077] In one embodiment, the above-mentioned scheduling of the second thread to continue processing the tasks in the target task flow starting from the first task may include: when the first thread stops processing the target task flow, controlling the timer to start timing from zero; when the timing time exceeds a preset time, scheduling the second thread to continue processing the tasks in the target task flow starting from the first task.

[0078] Exemplarily, the preset time may be 10 seconds, 30 seconds, or one minute, etc. This preset time may be implemented in the scheduling policy. In some examples, the maximum number of executions of the target task flow may also be set in the scheduling policy. The maximum number of executions is the statistical number of times the task flow continues to execute again after the task flow is suspended. Of course, in some examples, a scheduling policy that is always executed may also be set, that is, the maximum number of executions of the task flow is not limited.

[0079] According to the above implementation, after the first thread stops executing the target task flow, it can be restarted at a preset time interval to continue executing the task flow. At this time, the task flow can be executed again without the user issuing an instruction.

[0080] In some embodiments, a target thread pool may be determined in the first thread pool and the second thread pool based on the length of the code corresponding to the target task flow, and then a target thread may be determined from the target thread pool to execute tasks in the target task flow.

[0081] In one embodiment, the step of scheduling the first thread to process tasks in the target task flow starting from the first task arranged in the target task flow may include: when the attribute information of the target task flow meets a preset condition, scheduling the first thread to process tasks in the target task flow starting from the first task arranged in the target task flow; wherein the attribute information includes at least one of the task flow type and the total number of tasks in the task flow.

[0082] Exemplarily, the preset condition may be that the task flow type of the target task flow is a preset type. Alternatively, the preset condition may be that the total number of tasks in the target task flow is less than or equal to a preset number threshold. It is understandable that the tasks in the target task flow may be an associated task flow of the target task flow, and the associated task flow may include multiple tasks. Alternatively, the preset condition may be the amount of data processed by the task flow.

[0083] In some examples, the processing time of the target task flow is estimated by using the amount of context data to be processed by each task in the target task flow; when the processing time is less than the preset time, the first thread is scheduled to process the tasks in the target task flow starting from the task ranked first in the target task flow.

[0084] It can be understood that the target task flow includes multiple tasks, each of which uses one or more program functions to perform the task, and the amount of context data to be processed by each program function is different. Therefore, the amount of context data to be processed by each program function corresponding to the target task flow is accumulated to obtain the total amount of data. Thus, the processing time of the target task flow is estimated using the total amount of data. For example, the larger the total amount of data, the longer the processing time.

[0085] Exemplarily, when the total code length is less than a preset length, a first thread is selected from the first thread pool, and then the first thread is scheduled to process tasks in the target task flow starting from the task that is first arranged in the target task flow.

[0086] It can be understood that if the total amount of data is greater than the preset duration, it means that the execution cycle or duration is long, and it is placed in the slow pool for slow execution. If the total amount of data is less than this value, it is placed in the fast pool for execution. In this way, it can be ensured that the fast pool always executes operations with short processing cycles.

[0087] According to the above embodiment, when processing tasks for the target task flow for the first time, if the attribute information of the target task flow, such as the task flow type and / or the total number of tasks in the task flow, meets the preset conditions, the first thread with a faster processing speed is directly called to process the tasks in the target task flow starting from the first task in the target task flow. In this way, the overall task processing speed of the task scheduling system can be improved.

[0088] In one embodiment, the method may further include: scheduling the second thread to process tasks in the target task flow starting from the first task in the target task flow when the attribute information of the target task flow does not meet the preset condition.

[0089] It can be understood that the preset conditions are the same as the preset conditions mentioned above and will not be described in detail here.

[0090] In one example, when the processing time is longer than a preset time, the second thread is scheduled to process the tasks in the target task flow starting from the task that is first arranged in the target task flow.

[0091] Exemplarily, when the processing duration is a preset duration, a second thread is selected from the second thread pool, and then the second thread is scheduled to process tasks in the target task flow starting from the task that is first arranged in the target task flow.

[0092] According to the above implementation, when processing tasks for the target task flow for the first time, if the attribute information of the code corresponding to the target task flow, such as the task flow type and / or the total number of tasks in the task flow, meets the preset conditions, the second thread with a slower processing speed is directly called to process the tasks in the target task flow starting from the first task in the target task flow. Subsequently, even if the operation status of a task in the target task flow is an exception processing status, it is not necessary to change the thread to execute the task, and it will not affect the faster task execution of the thread.

[0093] The embodiments of the present disclosure can be applied to cloud services. The cloud network controller is in the IaaS layer of the cloud business, which is the foundation of cloud services. The NFV (Network Functions Virtualization) controller is in the lower layer of the cloud network controller, which is more basic. The special position determines that the NFV controller should try not to use external components to prevent circular dependencies. However, the process of creating a virtual network element involves the operation of more than a dozen or even dozens of links, and the creation of different network elements is also different. Therefore, this requires the embodiments of the present disclosure to provide support for it so as to improve the task processing speed.

[0094] like Figure 3 As shown, the embodiment of the present disclosure can be applied to the task flow component. It runs with the business system in the form of code and tripartite package, and provides the task processing method of the present disclosure for the business system to call. The task flow component includes: task flow management method interface (FlowManager), execution pool (Executor), configuration parsing (Parser), scheduling policy (Schedule Policy), timing management (Timer), multi-node disaster recovery (HA), data interface (DAO) and a persistent data structure. Among them, the execution pool (Executor) includes a fast pool (Fast Pool) and a slow pool (Slow Pool).

[0095] 1. Configuration parsing (Parser)

[0096] When the task flow is initialized, the supported task flow types (FlowType) are loaded. Figure 4 As shown, the task flow type includes the task flow type name (FlowType name), the task list (Task list), and the task flow context data structure, and is registered in the task flow component through the task flow manager. The task list includes n ordered tasks, each of which includes: execution sequence number, task name, and associated code function. Figure 4 The task flow type names, task names, and associated code functions provided in are only examples and are not explained in detail here.

[0097] It can be understood that the task flow type can be a task flow template. When a user creates a task flow, the user can select a task flow type, and then the system combines the task data used to create the task flow into the task flow type to obtain the task flow.

[0098] The execution sequence number is a unique identifier in the task list. When executing the task flow, the tasks in the list will be executed from small to large according to the execution sequence number.

[0099] For the task name, it is unique in the task list and is used to identify the task.

[0100] The associated code function is used to identify the business function to be executed by the current task. The task flow component defines a standard execution function abstract method, in which the task flow instance, current task, and context data information can be received. At the same time, the function supports direct return or pointer method to return the following information: task execution status, context data information, exception information, and other extended information for the task flow component to perceive the task execution status. The business party achieves the goal of executing the task by implementing this function method in the customized business process and returning execution data.

[0101] 2. Task flow management

[0102] Create a task flow: call the corresponding API (Application Programming Interface) and specify the task flow type (FlowType). The task flow manager will persist the task flow data configuration to the task flow table according to the configuration description of the task flow type, and return the unique task flow identifier in the task flow table. Specifically, when creating a task flow, it also includes the scheduling strategy of this task flow, such as the maximum number of scheduling times and the scheduling time interval, as well as the context data that the execution of this task flow depends on.

[0103] Trigger the execution of a task flow: call the corresponding API and specify the task flow identifier to complete the trigger. The task flow management program will query the task flow data from the database, and execute the program functions associated with each task in the task flow in sequence according to the description in the task flow data, and pass the context data in the task flow as an input parameter to this function. In addition, the task flow in the canceled state can be rescheduled through the trigger interface, and when it is rescheduled, it will continue to execute from the last failed task in the task flow.

[0104] Pause or cancel the execution of a task flow: call the corresponding API and specify the task flow identifier to complete. After the operation instruction is issued, the instruction is saved in a task flow state change table, which includes the task flow identifier and the operation status. The operation status can be a paused state or a canceled state. The task flow manager will synchronize this table to the memory at regular intervals. In this way, before each task in the task flow is executed, a specific area in the memory is searched to see whether there is an operation status of the currently executed task flow. For example, if the operation status is a paused state, then if there is a paused state at this time, the execution of the task flow is paused, and the operation status of the current task is set to completed, and the specified memory entry is cleared.

[0105] In this way, before each task starts executing, the memory is checked. If there is a record in the memory that the task flow corresponding to the task is in the canceled or paused state, the execution of the task is canceled or paused, and the task state flow is transferred to the canceled or tentative state, thereby achieving the effect of task interception.

[0106] Create associations between task flows: Call the corresponding API, specify the parent task flow ID and the child task flow ID to associate the association. The association is saved in a task flow relationship table, and the records in the table can describe multiple parent-child relationships such as 1 to 1, 1 to many, and many to 1. This can support task flow nesting and subtask parallel execution design.

[0107] Query the execution status of tasks and subtasks: Support querying the execution status of all tasks in the corresponding task flow through the task flow ID and task ID.

[0108] 3. Execution Pool

[0109] The task flow is executed in two groups of thread (coroutine) pools, one group is called the fast pool and the other group is called the slow pool. Newly triggered requests will be executed in the fast pool first. When the task execution enters Failed or Pending, it will be scheduled to execute in the slow pool.

[0110] 4. Master module selection and disaster recovery strategy

[0111] When the task flow component executes the task flow, there is a master election process. The time of this process is configurable, usually about 3 to 5 seconds. The task flow has a maximum execution time. The task flow node that successfully elects the master will be responsible for checking whether there are task flows running on other nodes that have been in the initialization state or the processing state, and check whether the last modification time of the operation status of the task flow to the current time exceeds the maximum execution time. If the maximum execution time is exceeded, the master node will take over the task flow and continue to execute the tasks in the task flow.

[0112] 5. Optimization to speed up execution

[0113] Since querying information or data from the database is slow, the speed of information query during the task flow execution process can also be accelerated by using memory or external Redis cache.

[0114] Figure 5 It is a structural block diagram of a task processing device according to an embodiment of the present disclosure.

[0115] like Figure 5 As shown, the task processing device may include:

[0116] A first task processing module 510 is used to schedule a first thread to process tasks in the target task flow starting from the first task in the target task flow in response to a processing request for the target task flow;

[0117] A second task processing module 520 is used to stop the first thread from processing the tasks in the target task flow when the first task in the target task flow is in a processing exception state, and schedule the second thread to continue processing the tasks in the target task flow starting from the first task;

[0118] The processing speed of the first thread is greater than the processing speed of the second thread.

[0119] Figure 6 It is a structural block diagram of a task processing device according to another embodiment of the present disclosure.

[0120] like Figure 5 and Figure 6 As shown, Figure 6 The first task processing module 610 and the second task processing module 620 in Figure 5 The first task processing module 510 and the second task processing module 520 have the same structure and function, which will not be described in detail here.

[0121] In one embodiment, the first thread is located in a first thread pool, the second thread is located in a second thread pool, the first thread pool includes multiple threads, the second thread pool includes multiple threads, and the processing speed of any thread in the first thread pool is greater than the processing speed of any thread in the second thread pool.

[0122] In one embodiment, Figure 6 As shown, the second task processing module 620 includes:

[0123] The first updating unit 621 is used to update the operation state of the target task flow in the first task flow state change table from the processing state to the suspended processing state in the task database;

[0124] A second updating unit 622 is used to update the second task flow state change table in the cache based on the updated first task flow state change table, so that the operation state of the target task flow in the second task flow state change table is updated from the processing state to the suspended processing state;

[0125] The second task flow state change table is used for the first thread to query the execution state of the target task flow in the cache when the adjacent second task in the target task flow is in a successfully processed state and the third task is in an unprocessed state, wherein the execution order of the second task is greater than the execution order of the third task;

[0126] The first thread is used for stopping processing tasks in the target task flow when it is found in the cache that the operation state of the target task flow is a suspended processing state.

[0127] In one embodiment, the device further comprises:

[0128] A timing module 630, configured to control a timer to start timing from zero when the first thread stops executing the target task flow;

[0129] A first updating module 640 is used to update the operation state of the target task flow in the first task flow state change table from a paused state to a processing state when the timed time exceeds a preset time;

[0130] The second updating module 650 is used to update the second task flow state change table in the cache based on the updated first task flow state change table, so that the operation state of the target task flow in the second task flow state change table is updated from the paused state to the processing state.

[0131] In one implementation, the second task processing module 620 is specifically configured to:

[0132] When the timed time exceeds the preset time, the second thread is scheduled to continue processing the tasks in the target task flow starting from the first task.

[0133] In one implementation, the first task processing module 610 includes:

[0134] A code length determining unit 611 is used to accumulate the code lengths corresponding to the program functions corresponding to the tasks in the target task flow to obtain a total code length;

[0135] The first thread scheduling unit 612 is used for scheduling the first thread to process the tasks in the target task flow starting from the first task in the target task flow when the total code length is less than a preset length.

[0136] In one implementation, the first task processing module 610 further includes:

[0137] The second thread scheduling unit 613 is used to schedule the second thread to process the tasks in the target task flow starting from the first task in the target task flow when the total code length is greater than the preset length.

[0138] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.

[0139] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0140] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium and a computer program product. The electronic device may be a server, and the server may also include any power supply control device in the embodiment of the present disclosure.

[0141] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0142] like Figure 7 As shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 707 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0143] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0144] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a task processing method. For example, in some embodiments, a task processing method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 707. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps in a task processing method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform a task processing method in any other appropriate manner (e.g., by means of firmware).

[0145] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0146] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0147] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0148] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0149] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0150] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0151] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0152] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A task processing method, include: In response to a processing request for a target task flow, scheduling a first thread to process tasks in the target task flow starting from the task that is first arranged in the target task flow; When the first task in the target task flow is in a processing exception state, stop the first thread from processing the tasks in the target task flow, and schedule the second thread to continue processing the tasks in the target task flow starting from the first task; The processing speed of the first thread is greater than the processing speed of the second thread.

2. The method according to claim 1, in, The first thread is located in a first thread pool, the second thread is located in a second thread pool, the first thread pool includes multiple threads, the second thread pool includes multiple threads, and the maximum number of parallel execution threads in the first thread pool is greater than the maximum number of parallel execution threads in the second thread pool.

3. The method according to claim 1 or 2, further comprising: include: In response to a pause processing instruction for the target task flow, in a task database, setting the target state of the target task flow in the first task flow state change table to a pause processing state; Based on the updated first task flow state change table, updating the second task flow state change table in the cache, so that the target state of the target task flow in the second task flow state change table is set to a suspended processing state; The second task flow state change table is used for the first thread to query the target state of the target task flow in the cache when the adjacent second task in the target task flow is in a processed state and the third task is in an unprocessed state, wherein the execution order of the second task is greater than the execution order of the third task; The first thread is used for stopping processing of the target task flow when it is found in the cache that the target state of the target task flow is a suspended processing state.

4. The method according to claim 1, in, The scheduling the second thread to continue processing the tasks in the target task flow starting from the first task includes: When the first thread stops processing the target task flow, controlling the timer to start timing from zero; When the timed time exceeds the preset time, the second thread is scheduled to continue processing the tasks in the target task flow starting from the first task.

5. The method according to claim 1, in, The scheduling first thread starts to process the tasks in the target task flow from the task that is first arranged in the target task flow, including: When the attribute information of the target task flow meets the preset condition, scheduling the first thread to process the tasks in the target task flow starting from the first task in the target task flow; The attribute information includes at least one of a task flow type and a total number of tasks in the task flow.

6. The method according to claim 5, further comprising: include: When the attribute information of the target task flow does not meet the preset condition, the second thread is scheduled to process the tasks in the target task flow starting from the task that is first arranged in the target task flow.

7. A task processing device, include: A first task processing module, configured to, in response to a processing request for a target task flow, schedule a first thread to process tasks in the target task flow starting from the task that is first arranged in the target task flow; A second task processing module is used to stop the first thread from processing the tasks in the target task flow when the first task in the target task flow is in a processing exception state, and schedule the second thread to continue processing the tasks in the target task flow starting from the first task; The processing speed of the first thread is greater than the processing speed of the second thread.

8. The device according to claim 7, in, The first thread is located in a first thread pool, the second thread is located in a second thread pool, the first thread pool includes multiple threads, the second thread pool includes multiple threads, and the maximum number of parallel execution threads in the first thread pool is greater than the maximum number of parallel execution threads in the second thread pool.

9. The device according to claim 7 or 8, further comprising: include: A first state setting module, in response to a pause processing instruction for the target task flow, sets the target state of the target task flow in the first task flow state change table to a pause processing state in the task database; A second state setting module, configured to update the second task flow state change table in the cache based on the updated first task flow state change table, so that the target state of the target task flow in the second task flow state change table is set to a suspended processing state; The second task flow state change table is used for the first thread to query the target state of the target task flow in the cache when the adjacent second task in the target task flow is in a processed state and the third task is in an unprocessed state, wherein the execution order of the second task is greater than the execution order of the third task; The first thread is used for stopping processing of the target task flow when it is found in the cache that the target state of the target task flow is a suspended processing state.

10. The device according to claim 7, in, The second task processing module includes: a timing unit, configured to control a timer to start timing from zero when the first thread stops processing the target task flow; The task processing unit is used to schedule the second thread to continue processing the tasks in the target task flow starting from the first task when the timed time exceeds the preset time.

11. The device according to claim 7, in, The first task processing module includes: A first thread scheduling unit, configured to schedule a first thread to process tasks in the target task flow starting from the first task in the target task flow if the attribute information of the target task flow meets a preset condition; The attribute information includes at least one of a task flow type and a total number of tasks in the task flow.

12. The device according to claim 11, wherein the first task processing module further include: The second thread scheduling unit is used to schedule the second thread to process the tasks in the target task flow starting from the first task in the target task flow when the attribute information of the target task flow does not meet the preset condition.

13. An electronic device, include: at least one central processing unit; as well as A memory in communication with the at least one central processing unit; wherein, The memory stores instructions that can be executed by the at least one central processor, and the instructions are executed by the at least one central processor to enable the at least one central processor to perform the method according to any one of claims 1 to 6.

14. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.

15. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.