Task management method and device, electronic equipment and storage medium

By judging and updating task status in timing task management, ensuring that tasks are executed when resources are sufficient, the problem of low task management accuracy in the existing technology is solved, and the stability and response speed of the system are improved.

CN119105845APending Publication Date: 2024-12-10SHENZHEN INTELLIFUSION TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410927271.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

The existing timing task management methods have low accuracy, resulting in large resource usage or hindering other tasks, affecting system response, and even causing crashes.

Method used

By judging the status of the target timing task, updating its status to the state to be executed, and executing the task when the resource conditions are met, using the task status as the management basis to accurately execute the corresponding management steps.

Benefits of technology

Improve the accuracy of task management, avoid resource waste and task conflicts, and ensure system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119105845A_ABST
    Figure CN119105845A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a task management method. The method comprises the steps of obtaining a target timed task and a task state of the target timed task from a task queue; if the task state of the target timed task is a non-execution state, judging whether the execution time of the target timed task is reached or not; if the execution time of the target timed task is reached, updating the task state of the target timed task into a to-be-executed state to obtain a to-be-executed timed task, and storing the to-be-executed timed task and the execution state; when the execution resources required by the to-be-executed timed task exist, the task state of the to-be-executed timed task is updated to be an in-execution state, and an in-execution timed task is obtained; and allocating an execution thread for the in-execution timed task, and performing execution processing on the in-execution timed task through the execution thread to obtain a task processing result. In the management process, the task state is used as a judgment basis for managing the timed task, so that the accuracy of task management can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data management, and in particular to a task management method, device, electronic equipment and storage medium. Background Art

[0002] With the development of information technology, the execution of scheduled tasks is increasingly used in various systems. At present, the execution of scheduled tasks is either a single serial or independent parallel, lacking unified scheduling and execution control of all scheduled tasks. However, the task management accuracy of this method is low, which often causes tasks that occupy a large number of resources to affect or hinder the execution of other tasks, and even affect the normal operation of the entire system, resulting in slow response or even crash of the entire system. Therefore, how to provide a method that can improve the accuracy of task management in scheduled task management has become an urgent problem to be solved. Summary of the invention

[0003] The embodiment of the present invention provides a task management method, which aims to solve the problem of low accuracy of the existing task management method. When the target scheduled task is in an unexecuted state, a judgment is made between executions, and after the judgment is passed, the task state is updated to a pending state, and at the same time, the task states of the pending scheduled task and the scheduled task to be executed are stored, and when the execution resources required for executing the scheduled task are met, the scheduled task is executed. Since the task state is used as a judgment basis for managing the scheduled task in the management process, the corresponding management steps are executed more accurately according to different task states, thereby improving the accuracy of task management.

[0004] In a first aspect, an embodiment of the present invention provides a task management method, the method comprising the following steps:

[0005] Acquire a target scheduled task and a task status of the target scheduled task from a task queue, wherein the task queue includes at least one scheduled task;

[0006] If the task status of the target scheduled task is not executed, determine whether the execution time of the target scheduled task has been reached;

[0007] If the execution time of the target scheduled task is reached, the task state of the target scheduled task is updated to a pending state, a pending scheduled task is obtained, and the pending scheduled task and the task state of the pending scheduled task are stored to wait for the allocation of execution resources;

[0008] When there are execution resources required to satisfy the scheduled task to be executed, the task state of the scheduled task to be executed is updated to an executing state to obtain the executing scheduled task;

[0009] An execution thread is allocated to the scheduled task in execution, and the scheduled task in execution is executed and processed by the execution thread to obtain a task processing result.

[0010] Optionally, before acquiring the target scheduled task in the task queue, the method further includes:

[0011] Acquire a first scheduled task from a first task source and a second scheduled task from a second task source, wherein the task status of the first scheduled task is a pending state or an executing state, and the execution status of the second scheduled task is a not executed state;

[0012] Filtering the first scheduled task and the second scheduled task to obtain a third scheduled task;

[0013] The third scheduled task is stored in the task queue, and the third scheduled task includes the target scheduled task.

[0014] Optionally, filtering the first scheduled task and the second scheduled task to obtain a third scheduled task includes:

[0015] Compare the task attributes of each of the first scheduled tasks with the task attributes of each of the second scheduled tasks one by one to obtain a comparison result of each of the first scheduled tasks;

[0016] When the comparison result is that there is no second scheduled task having the same task attribute as the corresponding first scheduled task, deleting the first scheduled task corresponding to the comparison result;

[0017] When the comparison result shows that there is a second scheduled task having the same task attributes as the corresponding first scheduled task, deleting the second scheduled task corresponding to the comparison result, and retaining the first scheduled task corresponding to the comparison result;

[0018] The first scheduled task that has not been deleted and the second scheduled task that has not been deleted are determined as the third scheduled task.

[0019] Optionally, the target scheduled task includes an execution type, the execution type includes fixed interval execution and specified time execution, the fixed interval time corresponds to a first execution strategy, the first execution strategy includes an interval time, the specified time execution corresponds to a second execution strategy, the second execution strategy includes an execution time point and a total number of executions within a preset time period, and the determining whether the execution time of the target scheduled task is reached includes:

[0020] Obtaining an execution record of the target scheduled task, wherein the execution record includes the number of executions;

[0021] When the execution type of the target scheduled task is the fixed interval execution, judging whether the execution time of the target scheduled task is reached based on the execution time and the interval time;

[0022] When the execution type of the target scheduled task is the specified time execution, calculating the difference between the total execution times and the execution times;

[0023] If the number of executions is less than the total number of executions, a target execution point is matched in the execution time point based on the difference, and the target execution point is compared with the current time to determine whether the execution time of the target scheduled task is reached.

[0024] Optionally, the execution resources include processor utilization and memory occupancy, and the allocation of waiting execution resources includes:

[0025] Calculating the processor resources required to execute the scheduled task to be executed based on the processor utilization of the scheduled task to be executed;

[0026] Comparing the processor resources with idle processor resources to obtain a processor occupancy comparison result;

[0027] Obtaining the currently used memory capacity and the total memory capacity, and determining the memory occupancy threshold of the to-be-executed scheduled task based on the currently used memory capacity and the total memory capacity;

[0028] Compare the memory occupancy rate of the scheduled task to be executed with the memory occupancy threshold to obtain a memory occupancy comparison result;

[0029] Based on the processor occupancy comparison result and the memory occupancy comparison result, it is determined whether there are execution resources required to meet the scheduled task to be executed.

[0030] Optionally, the scheduled task being executed is configured with a timeout period, and the executing thread is used to execute the scheduled task being executed to obtain a task processing result, including:

[0031] Monitoring the execution time of the scheduled task in execution;

[0032] When the execution time of the scheduled task in execution is greater than or equal to the timeout time, the execution of the scheduled task in execution is terminated, and the task state of the scheduled task in execution is set to an abnormal state, and the abnormal reason corresponding to the abnormal state is execution timeout;

[0033] When the scheduled task being executed is completed within the timeout period, the task state of the scheduled task being executed is set to a success state.

[0034] Optionally, the method further comprises:

[0035] If the task state of the target scheduled task before being stored in the task queue is in an executing state or a pending execution state, the target scheduled task is determined as the pending execution scheduled task to wait for allocation of execution resources.

[0036] In a second aspect, an embodiment of the present invention further provides a task management device, the task management device comprising:

[0037] A first acquisition module, used to acquire a target scheduled task and a task status of the target scheduled task from a task queue, wherein the task queue includes at least one scheduled task;

[0038] A first judgment module, used for judging whether the execution time of the target scheduled task has been reached if the task state of the target scheduled task is not executed;

[0039] A first updating module is used for updating the task status of the target scheduled task to a pending state if the execution time of the target scheduled task is reached, obtaining the pending scheduled task, and storing the pending scheduled task and the task status of the pending scheduled task to wait for the allocation of execution resources;

[0040] A second updating module is used to update the task state of the scheduled task to be executed to an executing state when there are execution resources required to satisfy the scheduled task to be executed, so as to obtain the scheduled task to be executed;

[0041] The first execution module is used to allocate an execution thread to the scheduled task in execution, and execute the scheduled task in execution through the execution thread to obtain a task processing result.

[0042] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the task management method provided in the embodiment of the present invention when executing the computer program.

[0043] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the task management method provided in the embodiment of the invention are implemented.

[0044] In an embodiment of the present invention, a target timed task and the task status of the target timed task are obtained from a task queue, wherein the task queue includes at least one timed task; if the task status of the target timed task is an unexecuted state, it is determined whether the execution time of the target timed task has been reached; if the execution time of the target timed task has been reached, the task status of the target timed task is updated to a pending state, a pending timed task is obtained, and the pending timed task and the task status of the pending timed task are stored to wait for the allocation of execution resources; when there are execution resources required to meet the pending timed task, the task status of the pending timed task is updated to an executing state, and an executing timed task is obtained; an execution thread is allocated to the executing timed task, and the executing timed task is executed and processed by the execution thread to obtain a task processing result. When the target timed task is in an unexecuted state, a judgment is made between executions, and after the judgment is passed, the task status is updated to a pending state, and the task status of the pending timed task and the pending timed task are stored, and when the execution resources required to execute the timed task are met, the timed task is executed. Since the task status is used as a basis for judging the management of scheduled tasks during the management process, corresponding management steps can be executed more accurately according to different task statuses, thereby improving the accuracy of task management. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] 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.

[0046] Figure 1 is a flow chart of a task management method provided by an embodiment of the present invention;

[0047] Figure 2 is a flow chart of another task management method provided by an embodiment of the present invention;

[0048] Figure 3 is a structural diagram of a task management device provided in an embodiment of the present invention;

[0049] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] like Figure 1 As shown, Figure 1 is a flowchart of a task management method provided by an embodiment of the present invention, including:

[0052] 101. Obtain the target scheduled task and the task status of the target scheduled task from the task queue.

[0053] In an embodiment of the present invention, the above-mentioned task management method can be applied to a task management system, the above-mentioned task management system can be deployed on a task management platform, the above-mentioned task management platform can be constructed by a server or a server cluster, and the above-mentioned server or server cluster can be any one or more electronic devices with functions such as data reading, data processing, task execution, and data transmission.

[0054] The above-mentioned scheduled tasks can be understood as code programs in computer software that run at specified times, dates or intervals. The above-mentioned task queue includes at least one scheduled task, and each of the above-mentioned scheduled tasks may correspond to task attributes and task status. The above-mentioned task attributes may include task name, task description, task priority, execution type, and execution resources required to execute the task. The above-mentioned task queue may be a queue arranged according to task priority, and the above-mentioned task priority may be set according to the execution condition of the task. For example, there are scheduled tasks A and scheduled tasks B in the above-mentioned task queue, wherein the execution condition of scheduled task B is that the execution result of the above-mentioned scheduled task A needs to be used, then the task priority of the above-mentioned scheduled task A is greater than that of the above-mentioned scheduled task B.

[0055] Specifically, all scheduled tasks that need to be managed in the task management system may be scanned to obtain the scheduled tasks to be managed, and the task queue may be generated based on the task priorities of the scheduled tasks to be managed.

[0056] The target scheduled task may be a scheduled task that needs to be managed currently. Each time, the scheduled task with the highest current priority is extracted from the task queue as the target scheduled task, and the task status of the target scheduled task is extracted from the task queue. The task status may include unexecuted status, pending status, executing status, abnormal status, and successful status.

[0057] 102. If the task status of the target scheduled task is not executed, determine whether the execution time of the target scheduled task has been reached.

[0058] In an embodiment of the present invention, the above-mentioned task management platform may include a database constructed according to a storage device, and the above-mentioned database may store execution records of the above-mentioned target scheduled tasks. When the task status corresponding to the above-mentioned target scheduled tasks is an unexecuted state, the execution records corresponding to the above-mentioned target scheduled tasks can be queried from the above-mentioned database, and through the execution records of the above-mentioned target scheduled tasks, it is determined whether the execution time of the target scheduled tasks has been reached.

[0059] Specifically, the execution type of the above-mentioned target timed task may include fixed interval execution and specified time execution. When the execution type of the above-mentioned target timed task is fixed interval time, the above-mentioned execution record can be used to determine whether the above-mentioned target timed task reaches the interval time required for the above-mentioned fixed interval, thereby judging whether the execution time of the above-mentioned target timed task is reached.

[0060] When the execution type of the target scheduled task is execution at a specified time, the time node of the current execution time required for the target scheduled task can be determined through the execution record, thereby determining whether the execution time of the target scheduled task has been reached.

[0061] 103. If the execution time of the target scheduled task is reached, the task state of the target scheduled task is updated to a pending execution state, the pending scheduled task is obtained, and the pending scheduled task and the task state of the pending scheduled task are stored to wait for the allocation of execution resources.

[0062] In the embodiment of the present invention, if the execution time of the target scheduled task is reached, the task state of the target scheduled task can be updated to a pending execution state. After the update, the target scheduled task is used as a pending execution scheduled task.

[0063] The above storage may be storing the data of the computing electronic device in a certain state in a storage device, and the above storage device may be equipped with the above database, that is, it can be understood that the task attributes, task status and other data of the above target scheduled task are stored in the above database.

[0064] Therefore, after the target scheduled task is used as the scheduled task to be executed, the scheduled task to be executed and the task attributes and task status of the scheduled task to be executed can be stored in the database to wait for the allocation of execution resources. During the waiting process, the execution resources required in the task attributes of the scheduled task to be executed and the idle execution resources of the task environment for executing the scheduled task to be executed can be compared. When the required execution resources are less than the idle execution resources, it means that there are execution resources required to meet the scheduled task to be executed. When the required execution resources are greater than or equal to the idle execution resources, it means that there are currently no execution resources required to meet the scheduled task to be executed.

[0065] After determining the above-mentioned target scheduled task as the above-mentioned scheduled task to be executed, the dynamic parameters of the above-mentioned scheduled task to be executed can also be generated by any dynamic parameter generation method. The above-mentioned dynamic parameters can be understood as parameters used to reconfigure the execution type of the above-mentioned scheduled task to be executed. For example, the execution type of the above-mentioned scheduled task to be executed can be configured as fixed interval execution or configured as specified time execution, or the interval time required for the fixed interval time can be specifically configured, or the number of executions and execution time points of the execution strategy corresponding to the specified time execution can be executed. It can be understood that there is a parameter generation interface corresponding to the scheduled task that requires dynamic parameters, and the dynamic parameter generation method therein can be implemented through the above-mentioned parameter generation results.

[0066] 104. When there are execution resources required to satisfy the scheduled task to be executed, the task state of the scheduled task to be executed is updated to an executing state, and the executing scheduled task is obtained.

[0067] In the embodiment of the present invention, when there are execution resources required to meet the above-mentioned scheduled task to be executed, the task state of the above-mentioned scheduled task to be executed can be updated to the executing state to obtain the above-mentioned executing scheduled task.

[0068] When there are no execution resources required to meet the above-mentioned scheduled task to be executed, the above-mentioned scheduled task to be executed can be placed in the above-mentioned task queue, waiting for the next round of extraction of the above-mentioned scheduled task to be executed, and then the task state of the above-mentioned scheduled task to be executed is updated to the executing state to obtain the above-mentioned executing scheduled task.

[0069] Alternatively, when there are no execution resources required to satisfy the above-mentioned scheduled task to be executed, the above-mentioned scheduled task to be executed can be retained until there are execution resources required to satisfy the above-mentioned scheduled task to be executed, and then the task state of the above-mentioned scheduled task to be executed is updated to the above-mentioned executing state to obtain the above-mentioned executing scheduled task.

[0070] 105. Allocate an execution thread for the scheduled task being executed, and execute the scheduled task being executed through the execution thread to obtain a task processing result.

[0071] In the embodiment of the present invention, the execution thread can be understood as the smallest unit in the execution of a computer program. A program can contain multiple threads, and each thread can independently execute a specific task. There can be a task manager in the task management system, and the task manager can be responsible for the scheduling of all scheduled tasks, the updating of task status, and the storage processing (i.e., storing the scheduled tasks and task status in the database).

[0072] After obtaining the above-mentioned scheduled task in execution, the above-mentioned execution thread can be allocated to the above-mentioned scheduled task in execution through the above-mentioned task manager, and the above-mentioned scheduled task in execution can be executed and processed by the above-mentioned execution thread to obtain the above-mentioned task processing result. The above-mentioned task processing result can correspond to the above-mentioned task status, and the above-mentioned task status includes the above-mentioned success status and the above-mentioned abnormal status. When the above-mentioned scheduled task in execution is completed within the preset time, the task status of the above-mentioned scheduled task in execution can be updated to the success status, and the above-mentioned task processing result is that the execution is completed.

[0073] When the execution time of the above-mentioned scheduled task exceeds the above-mentioned preset time, the execution of the above-mentioned scheduled task can be terminated, and the task status of the above-mentioned scheduled task can be updated to an abnormal state, the abnormal reason is execution timeout, and the above-mentioned task processing result is execution abnormality.

[0074] In an embodiment of the present invention, a target timed task and the task status of the target timed task are obtained from a task queue, wherein the task queue includes at least one timed task; if the task status of the target timed task is an unexecuted state, it is determined whether the execution time of the target timed task has been reached; if the execution time of the target timed task has been reached, the task status of the target timed task is updated to a pending state, a pending timed task is obtained, and the pending timed task and the task status of the pending timed task are stored to wait for the allocation of execution resources; when there are execution resources required to meet the pending timed task, the task status of the pending timed task is updated to an executing state, and an executing timed task is obtained; an execution thread is allocated to the executing timed task, and the executing timed task is executed and processed by the execution thread to obtain a task processing result. When the target timed task is in an unexecuted state, a judgment is made between executions, and after the judgment is passed, the task status is updated to a pending state, and the task status of the pending timed task and the pending timed task are stored, and when the execution resources required to execute the timed task are met, the timed task is executed. Since the task status is used as a basis for judging the management of scheduled tasks during the management process, corresponding management steps can be executed more accurately according to different task statuses, thereby improving the accuracy of task management.

[0075] It is understandable that in the specific implementation of this application, data related to scheduled tasks, execution records, task sources, etc. are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0076] It should be noted that the task management method provided in the embodiment of the present invention can be applied to devices such as computers and servers that can perform task management.

[0077] Optionally, before the step of obtaining the target scheduled task in the task queue, you can also obtain the first scheduled task of the first task source and the second scheduled task of the second task source, the task status of the first scheduled task is a pending state or an executing state, and the execution status of the second scheduled task is a not executed state; filter the first scheduled task and the second scheduled task to obtain a third scheduled task; store the third scheduled task in the task queue.

[0078] In an embodiment of the present invention, the first task source may be the database, in which the first scheduled task whose task status is to be executed or in execution is stored. The second task source may be a global scan of tasks performed by the task management system during initialization. The global scan may be understood as a scan of scheduled tasks existing in the task management system. Specifically, it may be a scheduled task scanned from a task processor during initialization, and its task status is unexecuted. The processor may be understood as an electronic device actually used to execute scheduled tasks. The third scheduled task includes the target scheduled task.

[0079] Normally, after the task management system is initialized, when obtaining the first scheduled task from the first task source, it is often empty, and the second scheduled task can only be obtained from the second task source. However, if the system is terminated or restarted before the task management system is initialized, and then the task management system is restarted, then since there may be scheduled tasks in the executing state or the waiting state in the database (i.e., the first task source), and the first scheduled task in the database may be repeated with the second scheduled task in the second task source, or the first scheduled task in the database exists but does not exist in the second scheduled task, it means that the first scheduled task has been It is no longer needed to be executed, therefore, after initialization, it is necessary to filter the above-mentioned first scheduled task and the above-mentioned second scheduled task to filter out the first scheduled task that no longer needs to be executed and the repeated second scheduled task. After filtering, the above-mentioned third scheduled task can be obtained, and based on the task priority of the above-mentioned third scheduled task, the above-mentioned task queue is generated. The above-mentioned queue may contain the third scheduled task sorted according to the above-mentioned task priority. There is at least one third scheduled task in the above-mentioned task queue. Subsequently, when judging the execution time of the third scheduled task, the third scheduled task with the highest task priority can be extracted from the task queue as the target scheduled task, and corresponding processing is performed.

[0080] It can be understood that after the above filtering process, the accuracy of the scheduled tasks can be guaranteed.

[0081] Optionally, in the step of filtering the first scheduled task and the second scheduled task to obtain the third scheduled task, the task attributes of each first scheduled task can also be compared one by one with the task attributes of each second scheduled task to obtain the comparison result of each first scheduled task; when the comparison result is that there is no second scheduled task with the same task attributes as the corresponding first scheduled task, the first scheduled task corresponding to the comparison result is deleted; when the comparison result is that there is a second scheduled task with the same task attributes as the corresponding first scheduled task, the second scheduled task corresponding to the comparison result is deleted, and the first scheduled task corresponding to the comparison result is retained; the undeleted first scheduled task and the undeleted second scheduled task are determined as the third scheduled task.

[0082] In the embodiment of the present invention, the above-mentioned sameness can be understood as the same task attributes (that is, the same task name, the same task description, the same execution type, and the same required execution resources). The task attributes of each first scheduled task are compared with the task attributes of each second scheduled task one by one to obtain the comparison result of each first scheduled task. The above-mentioned comparison result may be that there is no second scheduled task with the same task attributes as the first scheduled task, or there is a second scheduled task with the same task attributes as the first scheduled task. It should be noted that each comparison result corresponds to a first scheduled task, and there may be multiple second scheduled tasks. The second scheduled task may correspond to one comparison result or there may be no corresponding comparison result. When there is no corresponding comparison result, there is no need to determine whether the above-mentioned second scheduled task needs to be deleted.

[0083] The first scheduled task and the second scheduled task are filtered according to the comparison result of each first scheduled task. When the comparison result shows that there is no second scheduled task identical to the first scheduled task, it means that the first scheduled task has not written the second scheduled task identical to the first scheduled task before or during the system restart, and the first scheduled task no longer needs to be executed. Therefore, the first scheduled task corresponding to the comparison result can be deleted.

[0084] When the comparison result shows that there is a second scheduled task that is identical to the first scheduled task, it means that before the system restarts or during the system restart, the second scheduled task that is identical to the first scheduled task is written, and the first scheduled task still needs to be executed. In order to improve the task management efficiency, the first scheduled task corresponding to the comparison result can be retained (that is, the first scheduled task that has been stored in the database), and the second scheduled task corresponding to the comparison result (that is, the second scheduled task that has not been stored) can be deleted.

[0085] After all comparison results are determined, the first scheduled task that has not been deleted and the second scheduled task that has not been deleted are determined as the third scheduled task.

[0086] Optionally, in the step of determining whether the execution time of the target scheduled task has been reached, the execution record of the target scheduled task can also be obtained, the execution record including the number of executions; when the execution type of the target scheduled task is fixed interval execution, whether the execution time of the target scheduled task has been reached is determined based on the execution time and the interval time; when the execution type of the target scheduled task is specified time execution, the difference between the total number of executions and the number of executions is calculated; if the number of executions is less than the total number of executions, the target execution point is matched in the execution time point based on the difference, and the target execution point is compared with the current time to determine whether the execution time of the target scheduled task has been reached.

[0087] In an embodiment of the present invention, the target timed task includes an execution type, and the execution type includes fixed interval execution and specified time execution. Different execution types correspond to different execution strategies, the fixed interval execution corresponds to a first execution strategy, and the time execution corresponds to a second execution strategy. The first execution strategy includes an interval time, and the second execution strategy includes an execution time point within a preset time period and a total number of executions.

[0088] When the execution type of the above-mentioned target scheduled task is fixed interval execution, the corresponding first execution strategy may be to determine whether the difference between the last execution time of the above-mentioned target scheduled task and the current time is greater than the above-mentioned interval time, and the above-mentioned first execution strategy includes the interval time.

[0089] If the difference between the last execution time of the target scheduled task in the execution record and the current time is greater than or equal to the interval time, it is determined that the execution time of the target scheduled task is reached. Specifically, the last execution time can be set as T1, the current time as T2, and the interval time as S, then T2-T1≥S needs to be satisfied.

[0090] When the execution type of the above-mentioned target scheduled task is execution at a specified time, the second execution strategy corresponding to the above-mentioned specified time execution may have two execution methods, for example, 06:20, 12:45, 18:30, 23:59 is executed 4 times a day at 6:20, 12:45, 18:30 and 23:59 respectively, or 06:20|12:45|18:30|23:59 is executed once a day at 6:20 or 12:45 or 18:30 or 23:59. The above-mentioned second execution strategy may include the execution time points and the total number of executions within a day.

[0091] Therefore, when the above-mentioned target scheduled task is executed at a specified time, its execution method can be analyzed first to calculate the above-mentioned total execution times (that is, the total execution times of one day E1) and each execution time point (that is, ET[Et1, Et2, Et3...]), and then judge whether the above-mentioned execution times (E2) are less than the above-mentioned total execution times (E1) according to the execution record of the target task in the execution record. If E1≤E2, it is considered that the execution point has not been reached. Otherwise, it is necessary to judge the execution time and calculate the number of unexecuted times (that is, the above-mentioned difference) En=[E1-E2]. According to En, match the next execution time Etn (that is, the above-mentioned target execution point) at each execution time point to judge whether Etn is less than or equal to the current time. If so, it is judged that the execution time of the target scheduled task has been reached. If not, it is judged that the execution time of the target scheduled task has not been reached.

[0092] For example, if the total number of executions is 5, the execution points include ET[Et1, Et2, Et3, Et4, Et5], and the number of executions is 3, then the total number of executions and the number of executions are substituted into En=[E1-E2], and the number of non-executions can be calculated to be 2. According to the number of non-executions, the next execution time (i.e., target execution point) is matched to Et4 in the ET, and it is determined whether Et4 is less than or equal to the current time. If it is less than or equal to the current time, it is determined that the execution time of the target scheduled task has been reached. If Et4 is greater than the current time, it is determined that the execution time of the target scheduled task has not been reached.

[0093] Alternatively, if the total number of executions is 1, and the execution points include ET[Et1, Et2, Et3, Et4, Et5], and the number of executions is 0, then the number of non-executions is 1. At this time, the execution point equal to the current time can be used as the next execution time (i.e., the target execution point), or any execution point greater than the current time can be used as the next execution time (i.e., the target execution point).

[0094] It should be noted that the preset time period can be the above-mentioned day, or other time periods set according to different time measurement units, for example, one week, one month, one year, 10 days, 50 days, etc. The specific time period can be set according to actual usage requirements. When the execution time of the target scheduled task is not reached, a new target scheduled task can be re-extracted from the above-mentioned task queue, and the above-mentioned judgment process is repeated.

[0095] Optionally, in the step of waiting for allocation of execution resources, the processor resources required to execute the scheduled task to be executed can also be calculated based on the processor utilization of the scheduled task to be executed; the processor resources are compared with the idle processor resources to obtain a processor occupancy comparison result; the currently used memory capacity and the total memory capacity are obtained, and based on the currently used memory capacity and the total memory capacity, the memory occupancy threshold of the scheduled task to be executed is determined; the memory occupancy rate of the scheduled task to be executed is compared with the memory occupancy threshold to obtain a memory occupancy comparison result; based on the processor occupancy comparison result and the memory occupancy comparison result, it is determined whether there are execution resources required to meet the scheduled task to be executed.

[0096] In an embodiment of the present invention, the execution resources include processor utilization and memory occupancy. The processor utilization of the scheduled task to be executed can be understood as the ratio of processor resources required for the scheduled task to be executed if the scheduled task to be executed is required. The processor resources required for executing the scheduled task to be executed are calculated based on the processor utilization. When the processor resources are greater than the idle processor resources, it means that the idle resources of the processor are insufficient to run the scheduled task to be executed. At this time, the processor occupancy comparison result is a comparison failure. Otherwise, the processor occupancy comparison result is a pass.

[0097] Specifically, the above memory usage threshold can be calculated by the following formula:

[0098]

[0099] Among them, the above-mentioned MS is the above-mentioned memory occupation threshold, the above-mentioned M1 is the above-mentioned total memory capacity, and the above-mentioned M2 is the free memory capacity. The above-mentioned currently used memory capacity can be obtained by subtracting the above-mentioned free memory capacity from the above-mentioned total memory capacity.

[0100] When the memory usage rate is greater than the memory usage threshold, it means that the memory capacity is insufficient to run the scheduled task to be executed. At this time, the memory usage comparison result is failed. Otherwise, the memory usage comparison result is the same.

[0101] When both the memory occupancy comparison result and the processor occupancy comparison result are passed, it is determined that there are execution resources required to meet the scheduled task to be executed. When either the memory occupancy comparison result or the processor occupancy comparison result is failed, there are no execution resources required to meet the scheduled task to be executed.

[0102] Optionally, in the step of executing the scheduled task in execution through the execution thread to obtain the task processing result, the execution time of the scheduled task in execution can also be monitored; when the execution time of the scheduled task in execution is greater than or equal to the timeout time, the execution of the scheduled task in execution is terminated, and the task status of the scheduled task in execution is set to an abnormal state, and the abnormal reason corresponding to the abnormal state is execution timeout; when the scheduled task in execution is completed within the timeout time, the task status of the scheduled task in execution is set to a successful state.

[0103] In an embodiment of the present invention, the above-mentioned scheduled task in execution is configured with a timeout period. During the process of executing the above-mentioned scheduled task in execution through the above-mentioned execution thread, the execution time of the above-mentioned scheduled task in execution can also be monitored through the above-mentioned task manager. When the above-mentioned execution time is greater than or equal to the above-mentioned timeout period, the execution of the above-mentioned scheduled task in execution is terminated through the above-mentioned task manager, and the task state of the above-mentioned scheduled task in execution is set to an abnormal state, and the abnormal cause corresponding to the above-mentioned abnormal state is execution timeout.

[0104] If the above-mentioned scheduled task in execution is completed within the above-mentioned timeout period, the task status of the above-mentioned scheduled task in execution can be set to a successful status. At the same time, the above-mentioned scheduled task in execution can also be deleted from the above-mentioned database after the execution is completed.

[0105] In the process of monitoring the execution time through the task manager, the execution progress of the scheduled task being executed and the dynamic parameters of the scheduled task being executed can also be obtained through the task manager, and a corresponding monitoring log can be generated.

[0106] Optionally, the method further includes determining the target scheduled task as a scheduled task to be executed if the task state of the target scheduled task before being stored in the task queue is an executing state or a pending execution state, so as to wait for allocation of execution resources.

[0107] In an embodiment of the present invention, if the task status of the above-mentioned target scheduled task before being stored in the above-mentioned task queue is in an executing state or a pending execution state, it means that the above-mentioned target scheduled task is a scheduled task from the first task source (i.e., the database), the execution time has been determined, and it is stored in the database. At the same time, since the scheduled task originated from the first task source is a scheduled task retained in the database after the task management system is terminated or restarted, although the task status is in executing or pending execution, the execution thread assigned to it is also interrupted after the termination or restart, and the execution thread needs to be reassigned to it.

[0108] Therefore, there is no need to repeatedly store the target scheduled task in the database and determine the execution time. The target scheduled task can be directly determined as a scheduled task to be executed to wait for allocation of execution resources.

[0109] like Figure 2 As shown, the embodiment of the present invention also provides another task management method, including an initialization part and a core part. The initialization part includes the following steps:

[0110] The first step is to scan all scheduled tasks and their related attributes (i.e. the above-mentioned task attributes), including task name, task description, task priority, fixed interval execution, specified time point execution, execution timeout, maximum CPU utilization, and maximum memory usage.

[0111] The second step is to parse the properties of each scheduled task and verify the correctness of the above properties. For example, you can verify whether the above scheduled task is configured with a task priority, and verify that only one of the two execution types, fixed interval execution and specified time point execution, exists. If the priority is configured and only one of the above execution types exists, the correctness check passes, otherwise the correctness check fails.

[0112] The third step is to put the tasks that have passed the scan and verification into the task group. It should be noted that when putting them into the above task group, they can be put in randomly, or the above scheduled tasks can be put into the above task group in sequence according to the task priority of the scheduled tasks.

[0113] The fourth step is to traverse the tasks in the task group.

[0114] Step 5: Read the latest configuration of each scheduled task from the configuration file.

[0115] Step 6. If the third step is random placement, the scheduled tasks in the task group can be sorted according to task priority.

[0116] The core part includes the following steps:

[0117] The first step is to create a scheduled task manager. The task manager can be responsible for the scheduling of all scheduled tasks and the persistence of task status changes and information before and after update execution (i.e. the storage process, storing scheduled tasks and task status in the database). It can also terminate scheduled tasks during execution. In the task management system, there can be only one task manager, which can execute the following steps 2 to 18 at intervals of N seconds, where N can be configured according to actual conditions.

[0118] The second step is to query the database (i.e. the first task source) for tasks with a status of pending or executing. Normally, there will be no pending or executing tasks in the database when the second step is executed. If there are, it means that an unexpected termination or restart occurred before the system was started. Therefore, the second step is required to query the database to ensure the reliability of the scheduled task.

[0119] The third step is to obtain tasks through the task processor. All scheduled tasks in the system are obtained through the task processor. The task processor can read the configuration file information and the latest attribute configuration of the scheduled tasks in real time, which can ensure the flexibility of the scheduled tasks.

[0120] Step 4: The full and latest scheduled tasks are obtained in step 3, while the scheduled tasks obtained in step 2 are the scheduled tasks that were not completed before the system was started. It is possible that the scheduled tasks that need to be run in the system are updated, resulting in the deletion of tasks. Therefore, it is necessary to filter out the tasks that exist in step 2 but not in step 3 (expired tasks). For the tasks that exist in step 2 and step 3, only the tasks in step 2 need to be retained, so that the tasks that were not completed before the system was started can be executed first.

[0121] The fifth step is to put the filtered scheduled tasks obtained in step 4 (ie, the third scheduled tasks) into the task queue. The above-mentioned putting can also be putting the filtered scheduled tasks into the task queue in sequence according to the above-mentioned task priorities.

[0122] Step 6: Get the scheduled task in the task queue. It should be noted that this acquisition can be to extract the scheduled task with the highest priority from the task queue. If it cannot be extracted, it means that the current round of execution of the scheduled task manager has ended, waiting for the next round of execution, and jumping to step 2.

[0123] In the seventh step, if the task is obtained, it is necessary to judge the task status of the scheduled task. If the status is pending or executing, it means that the execution time has been verified and persisted. In this case, there is no need to perform the above operation and you can directly jump to the thirteenth step. Otherwise, the execution time verification of the following eighth step is required.

[0124] Step 8. There are two types of execution time verification: execution at fixed intervals and execution at specified time points.

[0125] Step 9. If the scheduled task is executed at a fixed interval, you can determine whether the difference between the last execution time and the current time is greater than the specified interval. If it is greater than or equal to the specified execution interval, the verification passes, otherwise the verification fails.

[0126] Step 10. If the scheduled task is executed at a specified time point, you can determine whether the number of executions is less than the total number of executions based on the total number of executions required for the scheduled task in a day and the various execution points, and then based on the number of executions and execution time in the execution record. If it is less than, determine the next execution time based on the execution time, and then determine whether the next execution time is less than or equal to the current time. If so, the verification passes, otherwise, the verification fails.

[0127] Step 11. If the execution time verification fails, jump to step 6. If the verification succeeds, execute the dynamic parameter generation method of the above-mentioned scheduled task (when registering a scheduled task that requires dynamic parameters, a parameter generation interface will be implemented, and the dynamic parameter generation method therein will be implemented. When the execution type of the scheduled task needs to be changed, it can be achieved by adjusting the dynamic parameters).

[0128] In the twelfth step, the status of the scheduled task is set to pending execution, and the relevant attributes of the task (i.e., task name, task description, task priority, execution at fixed intervals, execution at specified time points, execution timeout, maximum CPU utilization, maximum memory occupancy) and the dynamic parameters of the scheduled task (if dynamic parameters exist) are written into the database to complete the persistence processing.

[0129] Step 13: Verify whether the system resources meet the execution conditions of the scheduled task. If the task status obtained in step 7 is pending or executing, execute this step directly.

[0130] Step 14: Verify whether the CPU utilization is less than the limited CPU utilization. If so, the CPU resources meet the execution conditions of the scheduled task. Otherwise, they do not meet the conditions.

[0131] The fifteenth step verifies whether the memory usage is less than the limited memory threshold. If so, the memory resources meet the execution conditions of the scheduled task, otherwise, they do not meet the conditions.

[0132] Step 16. When all verifications are passed, set the task status of the scheduled task to executing.

[0133] Step 17: Call the scheduled task execution thread to execute the current task. At the same time, each scheduled task can obtain the status of the task during execution, update the execution progress of the task, and obtain the dynamic parameters in step 11 through the scheduled task assistant.

[0134] Step 18: After executing the scheduled task, the task manager will wait for the scheduled task to be executed. If the waiting time exceeds the timeout configured for the task, the task manager will terminate the execution of the task and set the task status to abnormal. The reason for the abnormality is the execution timeout. If the task is executed normally, the task status is set to success, and the current round of execution of the scheduled task manager ends.

[0135] like Figure 3 As shown, an embodiment of the present invention further provides a task management device, including:

[0136] A first acquisition module 301 is used to acquire a target scheduled task and a task status of the target scheduled task from a task queue, wherein the task queue includes at least one scheduled task;

[0137] The first judgment module 302 is used to judge whether the execution time of the target scheduled task has been reached if the task status of the target scheduled task is not executed;

[0138] The first updating module 303 is used for updating the task status of the target scheduled task to a pending state if the execution time of the target scheduled task is reached, obtaining the pending scheduled task, and storing the pending scheduled task and the task status of the pending scheduled task to wait for the allocation of execution resources;

[0139] The second updating module 304 is used to update the task state of the scheduled task to be executed to the executing state when there are execution resources required by the scheduled task to be executed, so as to obtain the executing scheduled task;

[0140] The first execution module 305 is used to allocate an execution thread to the scheduled task being executed, and execute the scheduled task being executed through the execution thread to obtain a task processing result.

[0141] Optionally, the task management device further includes:

[0142] A second acquisition module is used to acquire a first scheduled task from a first task source and a second scheduled task from a second task source, wherein the task status of the first scheduled task is a pending state or an executing state, and the execution status of the second scheduled task is a not executed state;

[0143] A filtering module, used for filtering the first scheduled task and the second scheduled task to obtain a third scheduled task;

[0144] A generating module is used to store the third scheduled task in the task queue, wherein the third scheduled task includes the target scheduled task.

[0145] Optionally, the filtering module includes:

[0146] A first comparison submodule, used for comparing the task attributes of each of the first scheduled tasks with the task attributes of each of the second scheduled tasks one by one, to obtain a comparison result of each of the first scheduled tasks;

[0147] A first deleting submodule, configured to, when the comparison result shows that there is no second scheduled task having the same task attribute as the corresponding first scheduled task, delete the first scheduled task corresponding to the comparison result;

[0148] A second deleting submodule is used for deleting the second scheduled task corresponding to the comparison result and retaining the first scheduled task corresponding to the comparison result when the comparison result shows that there is a second scheduled task with the same task attributes as the corresponding first scheduled task;

[0149] The first determining submodule is used to determine the first scheduled task that has not been deleted and the second scheduled task that has not been deleted as the third scheduled task.

[0150] Optionally, the target scheduled task includes an execution type, the execution type includes fixed interval execution and specified time execution, the fixed interval time corresponds to a first execution strategy, the first execution strategy includes an interval time, the specified time execution corresponds to a second execution strategy, the second execution strategy includes an execution time point within a preset time period and a total number of executions, the first judgment module 302 includes:

[0151] A first acquisition submodule is used to acquire the execution record of the target scheduled task, wherein the execution record includes the number of executions;

[0152] A first judgment submodule is used to judge whether the execution time of the target scheduled task is reached based on the execution time and the interval time when the execution type of the target scheduled task is the fixed interval execution;

[0153] A second judgment submodule is used to calculate the difference between the total execution times and the execution times when the execution type of the target scheduled task is the specified time execution;

[0154] The third judgment submodule is used to match the target execution point in the execution time point based on the difference if the execution number is less than the total execution number, and compare the target execution point with the current time to determine whether the execution time of the target scheduled task is reached.

[0155] Optionally, the execution resources include processor occupancy and memory occupancy, and the first updating module 303 includes:

[0156] A first calculation submodule, configured to calculate the processor resources required to execute the scheduled task to be executed based on the processor utilization of the scheduled task to be executed;

[0157] A first comparison submodule, used for comparing the processor resources with idle processor resources to obtain a processor occupancy comparison result;

[0158] A second acquisition submodule is used to acquire the currently used memory capacity and the total memory capacity, and determine the memory occupancy threshold of the scheduled task to be executed based on the currently used memory capacity and the total memory capacity;

[0159] A second comparison submodule is used to compare the memory occupancy rate of the scheduled task to be executed with the memory occupancy threshold to obtain a memory occupancy comparison result;

[0160] The second determination submodule is used to determine whether there are execution resources required to meet the scheduled task to be executed based on the processor occupancy comparison result and the memory occupancy comparison result.

[0161] Optionally, the scheduled task being executed is configured with a timeout period, and the first execution module 305 includes:

[0162] A first monitoring submodule, used to monitor the execution time of the scheduled task being executed;

[0163] A first setting submodule is used for terminating the execution of the scheduled task in execution when the execution time of the scheduled task in execution is greater than or equal to the timeout time, and setting the task state of the scheduled task in execution to an abnormal state, wherein the abnormal cause corresponding to the abnormal state is execution timeout;

[0164] The second setting submodule is used to set the task status of the scheduled task in execution to a success status when the scheduled task in execution is completed within the timeout period.

[0165] Optionally, the task management device further includes:

[0166] The first determination module is used to determine the target scheduled task as the to-be-executed scheduled task if the task state of the target scheduled task before being stored in the task queue is in the executing state or the to-be-executed state, so as to wait for the allocation of execution resources.

[0167] like Figure 4 As shown, an embodiment of the present invention further provides an electronic device, characterized in that it includes a processor, and the processor can execute any one of the above-mentioned task management methods.

[0168] Specifically, it includes a processor 401 and a memory 402, and a computer program for executing the task management method which is stored in the memory 402 and can be run on the processor 401, wherein:

[0169] The processor 401 runs the computer program of the task management method stored in the memory 402 to perform the following steps:

[0170] Acquire a target scheduled task and a task status of the target scheduled task from a task queue, wherein the task queue includes at least one scheduled task;

[0171] If the task status of the target scheduled task is not executed, determine whether the execution time of the target scheduled task has been reached;

[0172] If the execution time of the target scheduled task is reached, the task state of the target scheduled task is updated to a pending state, a pending scheduled task is obtained, and the pending scheduled task and the task state of the pending scheduled task are stored to wait for the allocation of execution resources;

[0173] When there are execution resources required to satisfy the scheduled task to be executed, the task state of the scheduled task to be executed is updated to an executing state to obtain the executing scheduled task;

[0174] An execution thread is allocated to the scheduled task in execution, and the scheduled task in execution is executed and processed by the execution thread to obtain a task processing result.

[0175] Optionally, before acquiring the target scheduled task in the task queue, the method executed by the processor 401 further includes:

[0176] Acquire a first scheduled task from a first task source and a second scheduled task from a second task source, wherein the task status of the first scheduled task is a pending state or an executing state, and the execution status of the second scheduled task is a not executed state;

[0177] Filtering the first scheduled task and the second scheduled task to obtain a third scheduled task;

[0178] The third scheduled task is stored in the task queue, and the third scheduled task includes the target scheduled task.

[0179] Optionally, the filtering of the first scheduled task and the second scheduled task to obtain a third scheduled task performed by the processor 401 includes:

[0180] Compare the task attributes of each of the first scheduled tasks with the task attributes of each of the second scheduled tasks one by one to obtain a comparison result of each of the first scheduled tasks;

[0181] When the comparison result is that there is no second scheduled task having the same task attribute as the corresponding first scheduled task, deleting the first scheduled task corresponding to the comparison result;

[0182] When the comparison result shows that there is a second scheduled task having the same task attributes as the corresponding first scheduled task, deleting the second scheduled task corresponding to the comparison result, and retaining the first scheduled task corresponding to the comparison result;

[0183] The first scheduled task that has not been deleted and the second scheduled task that has not been deleted are determined as the third scheduled task.

[0184] Optionally, the target scheduled task includes an execution type, the execution type includes fixed interval execution and specified time execution, the fixed interval time corresponds to a first execution strategy, the first execution strategy includes an interval time, the specified time execution corresponds to a second execution strategy, the second execution strategy includes an execution time point and a total number of executions within a preset time period, and the processor 401 performs the judgment of whether the execution time of the target scheduled task is reached, including:

[0185] Obtaining an execution record of the target scheduled task, wherein the execution record includes the number of executions;

[0186] When the execution type of the target scheduled task is the fixed interval execution, judging whether the execution time of the target scheduled task is reached based on the execution time and the interval time;

[0187] When the execution type of the target scheduled task is the specified time execution, calculating the difference between the total execution times and the execution times;

[0188] If the number of executions is less than the total number of executions, a target execution point is matched in the execution time point based on the difference, and the target execution point is compared with the current time to determine whether the execution time of the target scheduled task is reached.

[0189] Optionally, the execution resource includes processor utilization and memory occupancy, and the allocation of the waiting execution resource performed by the processor 401 includes:

[0190] Calculating the processor resources required to execute the scheduled task to be executed based on the processor utilization of the scheduled task to be executed;

[0191] Comparing the processor resources with idle processor resources to obtain a processor occupancy comparison result;

[0192] Obtaining the currently used memory capacity and the total memory capacity, and determining the memory occupancy threshold of the to-be-executed scheduled task based on the currently used memory capacity and the total memory capacity;

[0193] Compare the memory occupancy rate of the scheduled task to be executed with the memory occupancy threshold to obtain a memory occupancy comparison result;

[0194] Based on the processor occupancy comparison result and the memory occupancy comparison result, it is determined whether there are execution resources required to meet the scheduled task to be executed.

[0195] Optionally, the scheduled task being executed is configured with a timeout period, and the processor 401 executes the execution process of the scheduled task being executed through the execution thread to obtain the task processing result, including:

[0196] Monitoring the execution time of the scheduled task in execution;

[0197] When the execution time of the scheduled task in execution is greater than or equal to the timeout time, the execution of the scheduled task in execution is terminated, and the task state of the scheduled task in execution is set to an abnormal state, and the abnormal reason corresponding to the abnormal state is execution timeout;

[0198] When the scheduled task being executed is completed within the timeout period, the task state of the scheduled task being executed is set to a success state.

[0199] Optionally, the method executed by the processor 401 further includes:

[0200] If the task state of the target scheduled task before being stored in the task queue is in an executing state or a pending execution state, the target scheduled task is determined as the pending execution scheduled task to wait for allocation of execution resources.

[0201] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computer program implements the various processes of the task management method or the application-side task management method provided by the embodiment of the present invention, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0202] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the above-mentioned computer program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the above-mentioned computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0203] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A task management method, characterized in that: The method comprises the following steps: Acquire a target scheduled task and a task status of the target scheduled task from a task queue, wherein the task queue includes at least one scheduled task; If the task status of the target scheduled task is not executed, determine whether the execution time of the target scheduled task has been reached; If the execution time of the target scheduled task is reached, the task state of the target scheduled task is updated to a pending state, a pending scheduled task is obtained, and the pending scheduled task and the task state of the pending scheduled task are stored to wait for the allocation of execution resources; When there are execution resources required to satisfy the scheduled task to be executed, the task state of the scheduled task to be executed is updated to an executing state, thereby obtaining the executing scheduled task; An execution thread is allocated to the scheduled task in execution, and the scheduled task in execution is executed and processed by the execution thread to obtain a task processing result.

2. The task management method according to claim 1, characterized in that: Before acquiring the target scheduled task in the task queue, the method further includes: Acquire a first scheduled task from a first task source and a second scheduled task from a second task source, wherein the task status of the first scheduled task is a pending state or an executing state, and the execution status of the second scheduled task is a not executed state; Filtering the first scheduled task and the second scheduled task to obtain a third scheduled task; The third scheduled task is stored in the task queue, and the third scheduled task includes the target scheduled task.

3. The task management method according to claim 2, characterized in that: The filtering the first scheduled task and the second scheduled task to obtain a third scheduled task includes: Compare the task attributes of each of the first scheduled tasks with the task attributes of each of the second scheduled tasks one by one to obtain a comparison result of each of the first scheduled tasks; When the comparison result is that there is no second scheduled task having the same task attribute as the corresponding first scheduled task, deleting the first scheduled task corresponding to the comparison result; When the comparison result shows that there is a second scheduled task having the same task attributes as the corresponding first scheduled task, deleting the second scheduled task corresponding to the comparison result, and retaining the first scheduled task corresponding to the comparison result; The first scheduled task that has not been deleted and the second scheduled task that has not been deleted are determined as the third scheduled task.

4. The task management method according to any one of claims 1 to 3, characterized in that: The target timed task includes an execution type, and the execution type includes fixed interval execution and specified time execution. The fixed interval time corresponds to a first execution strategy, and the first execution strategy includes an interval time. The specified time execution corresponds to a second execution strategy, and the second execution strategy includes an execution time point and a total number of executions within a preset time period. The determining whether the execution time of the target timed task is reached includes: Obtaining an execution record of the target scheduled task, wherein the execution record includes the number of executions; When the execution type of the target scheduled task is the fixed interval execution, judging whether the execution time of the target scheduled task is reached based on the execution time and the interval time; When the execution type of the target scheduled task is the specified time execution, calculating the difference between the total execution times and the execution times; If the number of executions is less than the total number of executions, a target execution point is matched in the execution time point based on the difference, and the target execution point is compared with the current time to determine whether the execution time of the target scheduled task is reached.

5. The task management method according to any one of claims 1 to 3, characterized in that: The execution resources include processor utilization and memory occupancy, and the allocation of waiting execution resources includes: Calculating the processor resources required to execute the scheduled task to be executed based on the processor utilization of the scheduled task to be executed; Comparing the processor resources with idle processor resources to obtain a processor occupancy comparison result; Obtaining the currently used memory capacity and the total memory capacity, and determining the memory occupancy threshold of the to-be-executed scheduled task based on the currently used memory capacity and the total memory capacity; Compare the memory occupancy rate of the scheduled task to be executed with the memory occupancy threshold to obtain a memory occupancy comparison result; Based on the processor occupancy comparison result and the memory occupancy comparison result, it is determined whether there are execution resources required to meet the scheduled task to be executed.

6. The task management method according to claim 1, characterized in that: The scheduled task being executed is configured with a timeout period, and the executing thread is used to execute the scheduled task being executed to obtain a task processing result, including: Monitoring the execution time of the scheduled task in execution; When the execution time of the scheduled task in execution is greater than or equal to the timeout time, the execution of the scheduled task in execution is terminated, and the task state of the scheduled task in execution is set to an abnormal state, and the abnormal reason corresponding to the abnormal state is execution timeout; When the scheduled task being executed is completed within the timeout period, the task state of the scheduled task being executed is set to a success state.

7. The task management method according to claim 1, characterized in that: The method further comprises: If the task state of the target scheduled task before being stored in the task queue is in an executing state or a pending execution state, the target scheduled task is determined as the pending execution scheduled task to wait for allocation of execution resources.

8. A task management device, characterized in that: The task management device comprises: A first acquisition module, used to acquire a target scheduled task and a task status of the target scheduled task from a task queue, wherein the task queue includes at least one scheduled task; A first judgment module, used for judging whether the execution time of the target scheduled task has been reached if the task state of the target scheduled task is not executed; A first updating module is used for updating the task status of the target scheduled task to a pending state if the execution time of the target scheduled task is reached, obtaining the pending scheduled task, and storing the pending scheduled task and the task status of the pending scheduled task to wait for the allocation of execution resources; A second updating module is used to update the task state of the scheduled task to be executed to an executing state when there are execution resources required to satisfy the scheduled task to be executed, so as to obtain the scheduled task to be executed; The first execution module is used to allocate an execution thread to the scheduled task in execution, and execute the scheduled task in execution through the execution thread to obtain a task processing result.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the task management method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the task management method according to any one of claims 1 to 7 are implemented.