Add check for pending adhoc tasks before executing new Scheduled task #177
+25
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a check for pending adhoc tasks before executing a new scheduled task in the
cron_task
class. By doing so, it ensures that redundant executions of the reengagement cron task are avoided when there are already pending tasks. This is particularly important as Moodle does not create redundant adhoc tasks by itself, but scheduled tasks might generate a large number of adhoc tasks when there are many course modules. Without completing the previous iteration of adhoc tasks, creating new ones would just add to the queue, potentially creating a massive queue and possible bottleneck.Changes
classes/task/cron_task.php
- Added a method
has_pending_adhoc_tasks
to check for existing pending adhoc tasks.- Updated the
execute
method to skip execution if there are pending adhoc tasks.