A task processing method and device
By detecting and processing task subtasks in failed states in the data service system, the problems of waste of resources and inefficiency in the response failure state are solved, and more efficient task processing and response are achieved.
Patent Information
- Application Number
- CN202011219440.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-04
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-11-04
AI Technical Summary
In the data service system, re-responding to the data request in the response failed state consumes more system resources and time, resulting in a reduced efficiency of data request response.
By detecting tasks in the failed state in the task library, obtaining and processing binary identifiers of their subtasks, only subtasks in the failed state are reprocessed until successful, avoiding repeated processing of subtasks that have been successfully processed.
Save system resources, improve the efficiency of successful data request response, reduce unnecessary reprocessing, and improve task processing efficiency.
Smart Images

Figure CN112416545B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task processing method and device. Background Art
[0002] Currently, major data service providers can set up their own service systems and provide data services to the outside world.
[0003] For example, users can upload data requests to the service system, and the service system can respond to the data requests, for example, obtain the data that the user needs to access, and return the data that the user needs to access to the user, thereby providing data services to the user.
[0004] However, in the process of the service system responding to the data request, a variety of reasons may cause the response to the data request to fail, which makes it impossible to provide data services to users.
[0005] In order to provide data services to users, it is necessary to periodically poll the received data requests, and if a data request is found to be in a state of response failure, respond to the data request again until it is responded successfully.
[0006] However, the inventors have discovered that the process of re-responding to a data request that is in a failed response state consumes more system resources and takes more time, thereby reducing the efficiency of successfully responding to the data request. Summary of the invention
[0007] In order to save system resources and improve the efficiency of successfully responding to data requests, the present application shows a task processing method and device.
[0008] In a first aspect, the present application provides a task processing method, which is applied to an electronic device, and the method includes:
[0009] Based on a binary identifier used to characterize the processing status of each task in the task library, detecting whether there is a target task in a processing failure state in the task library;
[0010] In the case where the target task exists, obtaining a binary identifier for respectively characterizing the processing status of each subtask in the target task;
[0011] Based on the binary identifier used to respectively characterize the processing status of each subtask, searching for a target subtask in a processing failure state among the plurality of subtasks in the target task;
[0012] Process the target subtask.
[0013] In an optional implementation, the acquiring of binary identifiers for respectively characterizing the processing status of each subtask in the target task includes:
[0014] Obtaining a decimal identifier for characterizing a processing status of each subtask in the target task;
[0015] The decimal identifier number is converted into a binary string, wherein the binary string includes a binary identifier for respectively representing the processing status of each subtask in the target task.
[0016] In an optional implementation, the obtaining of a decimal identifier for characterizing the processing status of each subtask in the target task includes:
[0017] Obtaining a stored code, wherein the code is obtained by encoding the decimal identifier using a base64 encoding method when storing the decimal identifier in advance;
[0018] The encoding is decoded using a decoding method corresponding to the base64 encoding method to obtain the decimal identifier.
[0019] In an optional implementation, searching for a target subtask in a processing failure state among multiple subtasks in the target task based on a binary identifier for respectively characterizing the processing state of each subtask includes:
[0020] Searching the binary string for a binary identifier used to indicate that the processing status is a processing failure status;
[0021] Obtaining the position order of the found binary identifier in the binary string;
[0022] The subtask corresponding to the position sequence is determined as the target subtask.
[0023] In an optional implementation, after processing the target subtask, the method further includes:
[0024] When the target subtask is processed successfully, the binary identifier used to characterize the processing status of the target task is modified to a binary identifier used to characterize that the processing status is a successful processing status; and / or, the binary identifier used to characterize the processing status of the target subtask is modified to a binary identifier used to characterize that the processing status is a successful processing status.
[0025] In an optional implementation, the processing the target subtask includes:
[0026] The target subtask is stored in a task queue; and the target subtask in the task queue is processed serially asynchronously.
[0027] In an optional implementation, the method further includes:
[0028] In the task queue, the successfully processed target subtasks are deleted.
[0029] In an optional implementation, the method further includes:
[0030] After executing the step of detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library, the step of detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library is executed again at an interval of a preset time.
[0031] In an optional implementation, the method further includes:
[0032] The preset duration is adjusted according to the number of the target tasks and / or the number of target subtasks in the target task.
[0033] In an optional implementation, adjusting the preset duration according to the number of the target tasks and / or the number of target subtasks in the target task includes:
[0034] When the number of the target tasks is greater than a first preset threshold or the number of the target subtasks is greater than a second preset threshold, shortening the preset duration;
[0035] or,
[0036] When the number of the target tasks is less than or equal to a first preset threshold and the number of the target subtasks is less than or equal to a second preset threshold, the preset duration is extended.
[0037] In a second aspect, the present application shows a task processing device, which is applied to an electronic device, and the device includes:
[0038] a detection module, for detecting whether there is a target task in a processing failure state in the task library based on a binary identifier for characterizing a processing state of each task in the task library;
[0039] an acquisition module, used for acquiring, when the target task exists, a binary identifier for respectively representing a processing status of each subtask in the target task;
[0040] A search module, used for searching a target subtask in a processing failure state among a plurality of subtasks in the target task based on a binary identifier used to respectively characterize a processing state of each subtask;
[0041] A processing module is used to process the target subtask.
[0042] In an optional implementation, the acquisition module includes:
[0043] A first acquisition unit, used for acquiring a decimal identifier for representing a processing status of each subtask in the target task;
[0044] The conversion unit is used to convert the decimal identifier number into a binary string, wherein the binary string includes a binary identifier for respectively representing the processing status of each subtask in the target task.
[0045] In an optional implementation, the first acquiring unit includes:
[0046] An acquisition subunit, used for acquiring a stored code, wherein the code is obtained by encoding the decimal identifier using a base64 encoding method when storing the decimal identifier in advance;
[0047] The decoding subunit is used to decode the encoding using a decoding method corresponding to the base64 encoding method to obtain the decimal identifier.
[0048] In an optional implementation, the search module includes:
[0049] A searching unit, used for searching the binary identifier used to indicate that the processing status is a processing failure status in the binary string;
[0050] A second obtaining unit, used for obtaining the position sequence of the found binary identifier in the binary string;
[0051] A determination unit is used to determine the subtask corresponding to the position sequence as the target subtask.
[0052] In an optional implementation, the device further includes:
[0053] A modification module is used to modify the binary identifier used to characterize the processing status of the target task into a binary identifier used to characterize the processing status as a successful processing status when the target subtask is processed successfully; and / or, to modify the binary identifier used to characterize the processing status of the target subtask into a binary identifier used to characterize the processing status as a successful processing status.
[0054] In an optional implementation, the processing module includes:
[0055] A storage unit is used to store the target subtask in a task queue; and a processing unit is used to serially process the target subtask in the task queue.
[0056] In an optional implementation, the processing module further includes:
[0057] The deleting unit is used to delete the successfully processed target subtask in the task queue.
[0058] In an optional implementation, the detection module is further used to:
[0059] After detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library, at an interval of a preset time, detecting whether there is a target task in a processing failure state in the task library again based on the binary identifier used to characterize the processing status of each task in the task library.
[0060] In an optional implementation, the device further includes:
[0061] The adjustment module is used to adjust the preset duration according to the number of the target tasks and / or the number of target subtasks in the target task.
[0062] In an optional implementation, the adjustment module includes:
[0063] a shortening unit, configured to shorten the preset duration when the number of the target tasks is greater than a first preset threshold or the number of the target subtasks is greater than a second preset threshold;
[0064] or,
[0065] The extension unit is used to extend the preset duration when the number of the target tasks is less than or equal to a first preset threshold and the number of the target subtasks is less than or equal to a second preset threshold.
[0066] In a third aspect, the present application shows an electronic device, the electronic device comprising:
[0067] processor;
[0068] a memory for storing processor-executable instructions;
[0069] Wherein, the processor is configured to execute the task processing method as described in the first aspect.
[0070] In a fourth aspect, the present application illustrates a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the task processing method as described in the first aspect.
[0071] In a fifth aspect, the present application illustrates a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to perform the task processing method as described in the first aspect.
[0072] The technical solution provided by this application may have the following beneficial effects:
[0073] Based on the binary identifier used to characterize the processing status of each task in the task library, detect whether there is a target task in a processing failure state in the task library. In the case of a target task, obtain a binary identifier used to respectively characterize the processing status of each subtask in the target task. Based on the binary identifier used to respectively characterize the processing status of each subtask in the target task, search for a target subtask in a processing failure state among multiple subtasks in the target task. Process the target subtask.
[0074] It can be seen that in the present application, if there is a target task in the task library that is in a processing failure state, then if a subtask in the target task is in a processing failure state, the subtask can be re-executed until the subtask is successfully processed, thereby making the target task successfully processed. Through the present application, each subtask in the target task can be viewed and processed separately, and only the target subtask in the target task that is in a processing failure state can be reprocessed, and all the subtasks in the target task do not need to be reprocessed. In this way, the subtask in the target task that is in a processing success state does not need to be reprocessed, thereby reducing the number of subtasks in the target task that need to be reprocessed, thereby saving system resources, saving time, and improving the efficiency of successfully processing the target task. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Figure 1 It is a step flow chart of a task processing method of the present application.
[0076] Figure 2 It is a flowchart of the steps of a method for obtaining a binary identifier of the present application.
[0077] Figure 3 It is a structural block diagram of a task processing device of the present application.
[0078] Figure 4 It is a block diagram of an electronic device shown in the present application.
[0079] Figure 5It is a block diagram of an electronic device shown in the present application. DETAILED DESCRIPTION
[0080] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0081] Reference Figure 1 , shows a flowchart of a task processing method of the present application, the method is applied to electronic equipment, and the method may specifically include the following steps:
[0082] In step S101 , based on a binary identifier used to characterize the processing status of each task in the task library, it is detected in the task library whether there is a target task in a processing failure state.
[0083] In the present application, for an electronic device, the electronic device can store tasks that need to be processed in a task library, and then process the tasks in the task library.
[0084] For any task in the task library, the electronic device can obtain a binary identifier used to characterize the processing status of the task, and then detect whether the task is in a processing failure state based on the binary identifier used to characterize the processing status of the task. For each other task, the above operation is performed in the same way, thereby realizing the detection of whether there is a target task in the task library that is in a processing failure state.
[0085] Specifically, for any task in the task library, you can detect whether the task is in a processing failure state in the following ways, including:
[0086] 1011. Obtain a binary identifier for representing the processing status of the task.
[0087] Among them, whenever the electronic device obtains a task and stores the task in a task library and before the electronic device processes the task, the electronic device can set a binary identifier used to characterize the processing status of the task as a processing failure state, and then form a corresponding table entry with the task identifier of the task and the set binary identifier, and store it in the first corresponding relationship between the task identifier of the task and the binary identifier used to characterize the processing status of the task.
[0088] Furthermore, after the electronic device processes the task and successfully processes the task, the binary identifier corresponding to the task identifier of the task can be modified in the first corresponding relationship to a binary identifier used to indicate that the processing status is a successful processing status.
[0089] The binary identifier used to indicate that the processing status of the task is a processing failure status is different from the binary identifier used to indicate that the processing status of the task is a processing success status.
[0090] The binary identifier used to indicate that the processing status of a task is a processing failure status may be "0" or the like, and the binary identifier used to indicate that the processing status of a task is a processing success status may be "1" or the like, and this application does not impose any limitation on this.
[0091] Therefore, in step 1011, the task identifier of the task may be obtained, and then a binary identifier corresponding to the task identifier of the task and used to characterize the processing status of the task may be searched in the first corresponding relationship.
[0092] 1012. Determine whether the task is in a processing failure state based on the binary identifier.
[0093] In the present application, the binary identifier obtained for characterizing the processing status of the task may be used to characterize that the processing status of the task is a processing failure status, or may be used to characterize that the processing status of the task is a processing success status.
[0094] For example, when the binary identifier is used to represent that the processing state of the task is a processing failure state, it can be determined that the task is in a processing failure state, and then the task can be determined as a target task. When the binary identifier is used to represent that the processing state of the task is a processing success state, it can be determined that the task is in a processing success state.
[0095] In the case that there is a target task, in step S102 , a binary identifier for respectively characterizing the processing status of each subtask in the target task is obtained.
[0096] In this application, the target task may include at least two subtasks.
[0097] For example, suppose a user needs to publish social content on a social platform maintained by an electronic device, and the social content includes pictures and text. The user can upload a request to publish the social content to the electronic device. The electronic device receives the request to publish the social content and can treat the request as a task. The processing of the target task is the processing of the request. In this task, usually, the electronic device needs to process the picture into a picture of a uniform size and a uniform resolution, and then detect whether the text includes content that is not suitable for public release (such as illegal content or content that violates public order and good morals, etc.). If the text does not include content that is not suitable for release, the text and the processed picture are published as social content on the social platform.
[0098] Among them, "processing images into images of uniform size and resolution", "detecting whether the text contains content that is not suitable for public release" and "publishing the text and processed images as social content on social platforms" are three subtasks respectively.
[0099] Wherein, whenever the electronic device obtains a task and stores the task in the task library and before the electronic device processes the task, the electronic device can determine which subtasks are included in the task, and determine the position order of each subtask in the task. For any subtask included in the task, the electronic device can set a binary identifier for characterizing that the processing status of the subtask is a processing failure state. For each other subtask included in the task, the above operation is performed in the same way, so as to obtain a binary identifier for characterizing that the processing status of each subtask is a processing failure state, and then the binary identifiers corresponding to each subtask are combined according to the position order of each subtask in the task to obtain a binary string. Then, the task identifier of the task and the obtained binary string form a corresponding table item, and store it in the second corresponding relationship between the task identifier of the task and the binary string.
[0100] Furthermore, in the process of the electronic device processing the task later, if a subtask in the task is processed and the subtask is processed successfully, the binary identifier used to characterize the processing status of the subtask can be modified to a binary identifier used to characterize the processing status as a successful processing status in the binary string corresponding to the task identifier of the task in the second correspondence.
[0101] The binary identifier used to indicate that the processing status of the subtask is a processing failure status is different from the binary identifier used to indicate that the processing status of the subtask is a processing success status.
[0102] The binary identifier used to indicate that the processing status of a subtask is a processing failure status may be "0" or the like, and the binary identifier used to indicate that the processing status of a subtask is a processing success status may be "1" or the like, and this application does not impose any limitation on this.
[0103] Therefore, in this step, the task identifier of the target task can be obtained, and then the binary string corresponding to the task identifier of the target task can be searched in the second corresponding relationship to obtain each binary identifier in the binary string, thereby obtaining binary identifiers for respectively representing the processing status of each subtask in the target task.
[0104] In another embodiment of the present application, when the target task is in a successfully processed state, the process can be ended, or step S101 can be started again after a period of time.
[0105] In step S103 , based on the binary identifier used to respectively characterize the processing status of each subtask in the target task, a target subtask in a processing failure state is searched for among the multiple subtasks in the target task.
[0106] Among them, a binary identifier used to represent the processing status as a processing failure state can be searched among the binary identifiers used to respectively represent the processing status of each subtask in the target task, and the subtask corresponding to the found binary identifier is determined as the target subtask in the processing failure state.
[0107] In step S104, the target subtask is processed.
[0108] Further, in one embodiment of the present application, if there is one target subtask in the target task that is in a processing failure state, then when the target subtask is processed and successfully processed, it means that all subtasks in the target task have been successfully processed.
[0109] In this way, the binary identifier used to characterize the processing status of the target task can be modified to a binary identifier used to characterize that the processing status is a processing success status. For example, in the first corresponding relationship, the binary identifier corresponding to the task identifier of the target task can be modified to a binary identifier used to characterize that the processing status is a processing success status.
[0110] Furthermore, the binary identifier used to characterize the processing status of the target subtask may be modified to a binary identifier used to characterize that the processing status is a processing success status.
[0111] For example, in the binary string corresponding to the task identifier of the target task in the second corresponding relationship, the binary identifier used to characterize the processing status of the target subtask can be modified to a binary identifier used to characterize that the processing status is a processing success status.
[0112] Alternatively, in another embodiment of the present application, if there are at least two target subtasks in the target task that are in a processing failure state, then when at least two target subtasks are processed and the at least two target subtasks are processed successfully respectively, it means that all subtasks in the target task have been processed successfully.
[0113] In this way, the binary identifier used to characterize the processing status of the target task can be modified to a binary identifier used to characterize that the processing status is a processing success status. For example, in the first corresponding relationship, the binary identifier corresponding to the task identifier of the target task can be modified to a binary identifier used to characterize that the processing status is a processing success status.
[0114] Furthermore, the binary identifier used to characterize the processing status of each target subtask may be modified to a binary identifier used to characterize that the processing status is a processing success status.
[0115] For example, in the binary string corresponding to the task identifier of the target task in the second corresponding relationship, the binary identifier used to characterize the processing status of each target subtask can be modified into a binary identifier used to characterize that the processing status is a processing success status.
[0116] In this way, it is possible to avoid repeated processing of a target task that has been successfully processed, and to avoid repeated processing of a target subtask in a target task that has been successfully processed, thereby avoiding wasting system resources.
[0117] In the present application, based on the binary identifier used to characterize the processing status of each task in the task library, it is detected whether there is a target task in a processing failure state in the task library. In the case of a target task, a binary identifier used to characterize the processing status of each subtask in the target task is obtained. Based on the binary identifier used to characterize the processing status of each subtask in the target task, a target subtask in a processing failure state is searched among multiple subtasks in the target task. The target subtask is processed.
[0118] It can be seen that in the present application, if there is a target task in the task library that is in a processing failure state, then if a subtask in the target task is in a processing failure state, the subtask can be re-executed until the subtask is successfully processed, thereby making the target task successfully processed. Through the present application, each subtask in the target task can be viewed and processed separately, and only the target subtask in the target task that is in a processing failure state can be reprocessed, and all the subtasks in the target task do not need to be reprocessed. In this way, the subtask in the target task that is in a processing success state does not need to be reprocessed, thereby reducing the number of subtasks in the target task that need to be reprocessed, thereby saving system resources, saving time, and improving the efficiency of successfully processing the target task.
[0119] In the above-mentioned embodiment, the electronic device stores binary identifiers for representing the processing status of each subtask in the target task, that is, the electronic device stores several binary identifiers if there are several subtasks in the target task. However, when the number of subtasks included in the target task is large, the electronic device stores more binary identifiers, and more binary identifiers will occupy more storage space of the electronic device.
[0120] Therefore, in order to save storage space of the electronic device, in another embodiment of the present application, see Figure 2, step S102 includes:
[0121] In step S201 , a decimal identifier for characterizing the processing status of each subtask in the target task is obtained.
[0122] In the present application, the position order of each subtask in the target task can be set in advance, and then the binary identifiers used to characterize the processing status of each subtask in the target task can be combined into a binary string according to the position order of each subtask in the target task, and then the binary string is converted into decimal characters, and then the task identifier of the target task and the converted decimal characters are composed of corresponding table items, and stored in the third correspondence between the task identifier of the task and the decimal identifier used to characterize the processing status of each subtask in the task.
[0123] Thus, in this step, the task identifier of the target task may be obtained, and then the decimal identifier corresponding to the task identifier of the target task may be searched in the third corresponding relationship.
[0124] Among them, when the number of subtasks included in the target task is large, the space occupied by the binary string obtained by combining the binary identifiers used to represent the processing status of each subtask in the target task will be larger than the space occupied by the decimal characters converted from the binary string. Therefore, storing decimal identifiers can save storage space.
[0125] However, in the case where the decimal character is a UTL-8 encoded character, the decimal character may be escaped during the process of storing the decimal character in the electronic device, resulting in the decimal character being read later instead of the decimal character itself, which is an inaccurate decimal character. The subtask that is determined to be in a failed processing state based on the inaccurate decimal character may go wrong.
[0126] Therefore, in order to avoid this situation, before storing the decimal identifier, the decimal identifier can be encoded using base64 encoding to obtain a code, and then the task identifier of the target task and the code are composed of a corresponding table entry and stored in the fourth corresponding relationship between the task identifier and the code.
[0127] Thus, in this step, the stored code can be obtained, for example, the task identifier of the target task can be obtained, and then the code corresponding to the task identifier of the target task can be found in the fourth corresponding relationship. The code is obtained by encoding the decimal identifier using the base64 encoding method when storing the decimal identifier in advance, and then decoding the code using the decoding method corresponding to the base64 encoding method to obtain the decimal identifier. In this way, the decimal character obtained is the same as the decimal character that needs to be stored at the beginning, and is an accurate decimal character. It will not be wrong to determine the subtask in the processing failure state according to the accurate decimal character.
[0128] In step S202, the decimal identifier number is converted into a binary string, wherein the binary string includes a binary identifier for respectively representing the processing status of each subtask in the target task.
[0129] Furthermore, in step S103, a binary identifier used to characterize the processing status as a processing failure state can be searched for in the binary identifiers included in the binary string and used to respectively characterize the processing status of each subtask in the target task, and then the position sequence of the found binary identifiers in the binary string is obtained, and the subtask corresponding to the position sequence is determined as the target subtask in the processing failure state.
[0130] For example, it is assumed that the binary identifier used to indicate that the processing status of the subtask is a processing failure status is “0”, and the binary identifier used to indicate that the processing status of the subtask is a processing success status is “1”.
[0131] The target task includes 3 subtasks. The binary string corresponding to the target task is "011". The subtask corresponding to the binary identifier "0" in the first position is the first subtask in the target task. The subtask corresponding to the binary identifier "1" in the second position is the second subtask in the target task. The subtask corresponding to the binary identifier "1" in the third position is the third subtask in the target task.
[0132] The binary identifier "0" is at the first position in the binary string "011", so the first subtask corresponding to the first position can be determined as the target subtask in the processing failure state.
[0133] In one embodiment of the present application, when processing the target subtask in step S104, the target subtask may be stored in a task queue. Asynchronously, the target subtasks in the task queue may be processed serially.
[0134] In the present application, the process of storing the target subtask in the task queue and the process of processing the target subtask in the task queue can be executed by different threads in the electronic device respectively.
[0135] For example, the electronic device includes a task scheduling thread and a task processing thread, and the task scheduling thread and the task processing thread do not interfere with each other.
[0136] The electronic device may store the target subtask in the task queue based on the task scheduling thread, and the electronic device may process the target subtask in the task queue based on the task processing thread.
[0137] In this way, in the process of the electronic device storing target subtasks in the task queue based on the task scheduling thread, after starting to store a target subtask in the task queue, the electronic device can asynchronously start processing the target subtask in the task queue based on the task processing thread, avoiding the situation of "serial processing of target subtasks in the task queue only starts after all target subtasks are stored in the task queue", thereby improving task processing efficiency.
[0138] In one embodiment, the electronic device can process subtasks in the task queue in batches at the same time, that is, process multiple target subtasks in the task queue at one time. However, this will suddenly occupy more system resources in the electronic device, that is, it will cause a sudden increase in the utilization rate of the system resources of the electronic device, which will bring security risks to the electronic device.
[0139] Therefore, in order to avoid this situation, the electronic device can process the target subtasks in the task queue in serial, so as to avoid a sudden increase in the utilization of the system resources of the electronic device, thereby avoiding safety hazards to the electronic device.
[0140] Furthermore, in one embodiment of the present application, in the task queue, the successfully processed target subtasks may be deleted to avoid repeated processing of the successfully processed target subtasks, thereby avoiding wasting system resources.
[0141] For example, for any target subtask in the task processing queue, after the electronic device processes the target subtask once, if the target subtask is processed successfully, the target subtask can be deleted from the task queue; if the target subtask is not processed successfully, the target subtask is tried again until it is processed successfully, and then the target subtask can be deleted from the task queue.
[0142] The same is true for each other target subtask in the task processing queue.
[0143] However, in one embodiment of the present application, in order to ensure that the task in the failed processing state can be processed successfully as much as possible, the task can be executed at least once every preset time interval. Figure 1 In the embodiment shown, that is, the process of step S101 to step S104 is executed at least once at every preset time interval.
[0144] For example, in one example, after executing step S101 "based on the binary identifier used to characterize the processing status of each task in the task library, detecting whether there is a target task in the task library that is in a processing failure state", a preset time interval can be maintained, and then step S101 can be started again: based on the binary identifier used to characterize the processing status of each task in the task library, detecting whether there is a target task in the task library that is in a processing failure state.
[0145] However, in the aforementioned embodiment, for any target subtask in the task queue, if the target subtask is not processed successfully, the target subtask can be tried again until it is processed successfully, and then the target subtask can be deleted from the task queue.
[0146] However, after executing step S101, if the preset time has been reached, but the electronic device still has not successfully processed the target subtask, then after executing step S101 again, the target subtask will be repeatedly stored in the task queue, which may cause the target subtask to be repeatedly processed multiple times, thereby wasting system resources.
[0147] Therefore, in order to save system resources, in another embodiment of the present application, before storing the target subtask in the task queue, it can be determined whether the target subtask is stored in the task queue. If the target subtask is not stored in the task queue, the target subtask is stored in the task queue. If the target subtask has been stored in the task queue, the target subtask is not stored in the task queue, thereby avoiding repeated storage of the target subtask in the task queue, thereby avoiding repeated processing of the target subtask, and thus avoiding wasting system resources.
[0148] In the present application, the preset duration may be set in advance by a technician in the electronic device according to actual conditions, for example, it may include 1 second, 2 seconds or 5 seconds, etc., and the present application does not limit this.
[0149] In the aforementioned embodiment, the preset duration may be a fixed duration. However, sometimes, there are many target subtasks in the processing failure state, and sometimes, there are fewer target subtasks in the processing failure state.
[0150] Since the number of subtasks that an electronic device can process within a unit time is limited, when there are many target subtasks in a processing failure state, the preset time can be shortened in order to enable as many subtasks as possible to be processed successfully as soon as possible.
[0151] In the case where there are few target subtasks in the failed state, in order to avoid repeated and meaningless execution of at least Figure 1 The embodiment shown can save system resources of the electronic device and extend the preset time.
[0152] Therefore, the preset duration can be adjusted according to the number of target tasks and / or the number of target subtasks in the target task. The target subtasks in the target task include the sum of the number of target subtasks in each target task.
[0153] For example, when the number of target tasks is greater than a first preset threshold or the number of target subtasks is greater than a second preset threshold, the preset duration is shortened.
[0154] Specifically, a shorter preset duration can be used to replace the current preset duration. The shorter preset duration is shorter than the current preset duration. The specific determination method of the shorter preset duration can be determined according to the number of target tasks or the number of target subtasks, and this application does not limit the specific determination method.
[0155] On the premise that the number of target tasks is greater than the first preset threshold or the number of target subtasks is greater than the second preset threshold, the larger the number of target tasks or the number of target subtasks is, the shorter the preset duration is, and the smaller the number of target tasks or the number of target subtasks is, the longer the preset duration is.
[0156] Alternatively, when the number of target tasks is less than or equal to a first preset threshold and the number of target subtasks is less than or equal to a second preset threshold, the preset duration is extended.
[0157] Specifically, a longer preset duration can be used to replace the current preset duration. The longer preset duration is longer than the current preset duration. The specific determination method of the longer preset duration can be determined according to the number of target tasks and the number of target subtasks, and this application does not limit the specific determination method.
[0158] When the number of target tasks is less than or equal to the first preset threshold and the number of target subtasks is less than or equal to the second preset threshold, the larger the number of target tasks and the number of target subtasks are, the shorter the preset duration is; and the smaller the number of target tasks or the number of target subtasks is, the longer the preset duration is.
[0159] The first preset threshold and the second preset threshold can be determined according to actual conditions, and this application does not limit this.
[0160] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by the present application.
[0161] Reference Figure 3 , shows a structural block diagram of a task processing device of the present application, which may specifically include the following modules:
[0162] A detection module 11 is used to detect whether there is a target task in a processing failure state in the task library based on a binary identifier used to characterize the processing state of each task in the task library;
[0163] An acquisition module 12, used for acquiring binary identifiers for respectively representing the processing status of each subtask in the target task when the target task exists;
[0164] A search module 13, configured to search for a target subtask in a processing failure state among the multiple subtasks in the target task based on a binary identifier used to respectively characterize the processing state of each subtask;
[0165] The processing module 14 is used to process the target subtask.
[0166] In an optional implementation, the acquisition module includes:
[0167] A first acquisition unit, used for acquiring a decimal identifier for representing a processing status of each subtask in the target task;
[0168] The conversion unit is used to convert the decimal identifier number into a binary string, wherein the binary string includes a binary identifier for respectively representing the processing status of each subtask in the target task.
[0169] In an optional implementation, the first acquiring unit includes:
[0170] An acquisition subunit, used for acquiring a stored code, wherein the code is obtained by encoding the decimal identifier using a base64 encoding method when storing the decimal identifier in advance;
[0171] The decoding subunit is used to decode the encoding using a decoding method corresponding to the base64 encoding method to obtain the decimal identifier.
[0172] In an optional implementation, the search module includes:
[0173] A searching unit, used for searching the binary identifier used to indicate that the processing status is a processing failure status in the binary string;
[0174] A second obtaining unit, used for obtaining the position sequence of the found binary identifier in the binary string;
[0175] A determination unit is used to determine the subtask corresponding to the position sequence as the target subtask.
[0176] In an optional implementation, the device further includes:
[0177] A modification module is used to modify the binary identifier used to characterize the processing status of the target task into a binary identifier used to characterize the processing status as a successful processing status when the target subtask is processed successfully; and / or, to modify the binary identifier used to characterize the processing status of the target subtask into a binary identifier used to characterize the processing status as a successful processing status.
[0178] In an optional implementation, the processing module includes:
[0179] A storage unit is used to store the target subtask in a task queue; and a processing unit is used to serially process the target subtask in the task queue.
[0180] In an optional implementation, the processing module further includes:
[0181] The deleting unit is used to delete the successfully processed target subtask in the task queue.
[0182] In an optional implementation, the detection module is further used to:
[0183] After detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library, at an interval of a preset time, detecting whether there is a target task in a processing failure state in the task library again based on the binary identifier used to characterize the processing status of each task in the task library.
[0184] In an optional implementation, the device further includes:
[0185] The adjustment module is used to adjust the preset duration according to the number of the target tasks and / or the number of target subtasks in the target task.
[0186] In an optional implementation, the adjustment module includes:
[0187] a shortening unit, configured to shorten the preset duration when the number of the target tasks is greater than a first preset threshold or the number of the target subtasks is greater than a second preset threshold;
[0188] or,
[0189] The extension unit is used to extend the preset duration when the number of the target tasks is less than or equal to a first preset threshold and the number of the target subtasks is less than or equal to a second preset threshold.
[0190] Based on the binary identifier used to characterize the processing status of each task in the task library, detect whether there is a target task in a processing failure state in the task library. In the case of a target task, obtain a binary identifier used to respectively characterize the processing status of each subtask in the target task. Based on the binary identifier used to respectively characterize the processing status of each subtask in the target task, search for a target subtask in a processing failure state among multiple subtasks in the target task. Process the target subtask.
[0191] It can be seen that in the present application, if there is a target task in the task library that is in a processing failure state, then if a subtask in the target task is in a processing failure state, the subtask can be re-executed until the subtask is successfully processed, thereby making the target task successfully processed. Through the present application, each subtask in the target task can be viewed and processed separately, and only the target subtask in the target task that is in a processing failure state can be reprocessed, and all the subtasks in the target task do not need to be reprocessed. In this way, the subtask in the target task that is in a processing success state does not need to be reprocessed, thereby reducing the number of subtasks in the target task that need to be reprocessed, thereby saving system resources, saving time, and improving the efficiency of successfully processing the target task.
[0192] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0193] Figure 4 800 is a block diagram of an electronic device 800 shown in the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0194] Reference Figure 4 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0195] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0196] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, images, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0197] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0198] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0199] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0200] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0201] The sensor assembly 814 includes one or more sensors for providing status assessment of each aspect of the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0202] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast operation information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0203] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0204] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0205] Figure 5 1 is a block diagram of an electronic device 1900 shown in the present application. For example, the electronic device 1900 may be provided as a server.
[0206] Reference Figure 5 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0207] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output (I / O) interface 1958. The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0208] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between each embodiment can be referenced to each other.
[0209] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0210] The present application is described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0211] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0212] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0213] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0214] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0215] The above is a detailed introduction to a task processing method and device provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A task processing method, characterized in that: Applied to electronic equipment, the method comprises: Based on a binary identifier used to characterize the processing status of each task in the task library, detecting whether there is a target task in a processing failure state in the task library; In the case where the target task exists, obtaining binary identifiers for respectively characterizing the processing status of each subtask in the target task, including: obtaining the task identifier of the target task, searching for a binary string corresponding to the task identifier in a second corresponding relationship, obtaining each binary identifier in the binary string, wherein the second corresponding relationship stores a corresponding table item consisting of the task identifier of each task and the binary string of the task, and the binary identifiers corresponding to each subtask in the binary string are combined in order according to the position of each subtask in the target task; Based on the binary identifier used to respectively characterize the processing status of each subtask, searching for a target subtask in a processing failure state among the plurality of subtasks in the target task; Process the target subtask.
2. The method according to claim 1, characterized in that The obtaining of binary identifiers for respectively characterizing the processing status of each subtask in the target task includes: Obtaining a decimal identifier for characterizing a processing status of each subtask in the target task; The decimal identifier number is converted into a binary string, wherein the binary string includes a binary identifier for respectively representing the processing status of each subtask in the target task.
3. The method according to claim 2, characterized in that The step of obtaining a decimal identifier for characterizing the processing status of each subtask in the target task includes: Obtaining a stored code, wherein the code is obtained by encoding the decimal identifier using a base64 encoding method when storing the decimal identifier in advance; The encoding is decoded using a decoding method corresponding to the base64 encoding method to obtain the decimal identifier.
4. The method according to claim 2 or 3, characterized in that: The step of searching for a target subtask in a processing failure state among a plurality of subtasks in the target task based on a binary identifier for respectively characterizing the processing state of each subtask comprises: Searching the binary string for a binary identifier used to indicate that the processing status is a processing failure status; Obtaining the position order of the found binary identifier in the binary string; The subtask corresponding to the position sequence is determined as the target subtask.
5. The method according to claim 1, characterized in that After processing the target subtask, the method further includes: When the target subtask is processed successfully, the binary identifier used to characterize the processing status of the target task is modified to a binary identifier used to characterize that the processing status is a successful processing status; and / or, the binary identifier used to characterize the processing status of the target subtask is modified to a binary identifier used to characterize that the processing status is a successful processing status.
6. The method according to claim 1, characterized in that The processing of the target subtask includes: The target subtask is stored in a task queue; and the target subtask in the task queue is processed serially asynchronously.
7. The method according to claim 6, characterized in that The method further comprises: In the task queue, the successfully processed target subtasks are deleted.
8. The method according to claim 1 or 5, characterized in that: The method further comprises: After executing the step of detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library, the step of detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library is executed again at an interval of a preset time.
9. The method according to claim 8, characterized in that The method further comprises: The preset duration is adjusted according to the number of the target tasks and / or the number of target subtasks in the target task.
10. The method according to claim 9, characterized in that The adjusting the preset duration according to the number of the target tasks and / or the number of target subtasks in the target task includes: When the number of the target tasks is greater than a first preset threshold or the number of the target subtasks is greater than a second preset threshold, shortening the preset duration; or, When the number of the target tasks is less than or equal to a first preset threshold and the number of the target subtasks is less than or equal to a second preset threshold, the preset duration is extended.
11. A task processing device, characterized in that: Applied to electronic equipment, the device comprises: a detection module, for detecting whether there is a target task in a processing failure state in the task library based on a binary identifier for characterizing a processing state of each task in the task library; an acquisition module, used for acquiring, when the target task exists, a binary identifier for respectively representing a processing status of each subtask in the target task; A search module, used for searching a target subtask in a processing failure state among a plurality of subtasks in the target task based on a binary identifier used to respectively characterize a processing state of each subtask; A processing module, used for processing the target subtask; The binary identifier is obtained by a module in the device for performing the following process: Obtain the task identifier of the target task, search for the binary string corresponding to the task identifier in the second corresponding relationship, obtain each binary identifier in the binary string, store the corresponding table items consisting of the task identifier of each task and the binary string of the task in the second corresponding relationship, and the binary identifiers corresponding to each subtask in the binary string are combined in order according to the position of each subtask in the target task.
12. The device according to claim 11, characterized in that The acquisition module comprises: A first acquisition unit, used for acquiring a decimal identifier for representing a processing status of each subtask in the target task; The conversion unit is used to convert the decimal identifier number into a binary string, wherein the binary string includes a binary identifier for respectively representing the processing status of each subtask in the target task.
13. The device according to claim 12, characterized in that The first acquiring unit includes: An acquisition subunit, used for acquiring a stored code, wherein the code is obtained by encoding the decimal identifier using a base64 encoding method when storing the decimal identifier in advance; The decoding subunit is used to decode the encoding using a decoding method corresponding to the base64 encoding method to obtain the decimal identifier.
14. The device according to claim 12 or 13, characterized in that The search module includes: A searching unit, used for searching the binary identifier used to indicate that the processing status is a processing failure status in the binary string; A second obtaining unit, used for obtaining the position sequence of the found binary identifier in the binary string; A determination unit is used to determine the subtask corresponding to the position sequence as the target subtask.
15. The device according to claim 11, characterized in that The device also includes: A modification module is used to modify the binary identifier used to characterize the processing status of the target task into a binary identifier used to characterize the processing status as a successful processing status when the target subtask is processed successfully; and / or, to modify the binary identifier used to characterize the processing status of the target subtask into a binary identifier used to characterize the processing status as a successful processing status.
16. The device according to claim 11, characterized in that The processing module comprises: A storage unit is used to store the target subtask in a task queue; and a processing unit is used to serially process the target subtask in the task queue.
17. The device according to claim 16, characterized in that The processing module also includes: The deleting unit is used to delete the successfully processed target subtask in the task queue.
18. The device according to claim 11 or 15, characterized in that The detection module is also used for: After detecting whether there is a target task in a processing failure state in the task library based on the binary identifier used to characterize the processing status of each task in the task library, at an interval of a preset time, detecting whether there is a target task in a processing failure state in the task library again based on the binary identifier used to characterize the processing status of each task in the task library.
19. The device according to claim 18, characterized in that The device also includes: The adjustment module is used to adjust the preset duration according to the number of the target tasks and / or the number of target subtasks in the target task.
20. The device according to claim 19, characterized in that The adjustment module comprises: a shortening unit, configured to shorten the preset duration when the number of the target tasks is greater than a first preset threshold or the number of the target subtasks is greater than a second preset threshold; or, The extension unit is used to extend the preset duration when the number of the target tasks is less than or equal to a first preset threshold and the number of the target subtasks is less than or equal to a second preset threshold.
21. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; The processor is configured to execute the task processing method according to any one of claims 1 to 10.
22. A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the task processing method according to any one of claims 1 to 10.
