-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add django command for flushing huey storage
- useful in case the task locks get stuck: if this happens, the courses will not be built until the lock is flushed from the storage
- Loading branch information
1 parent
a5f79dc
commit 1f65aa3
Showing
4 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.core.management.base import BaseCommand | ||
from huey.contrib.djhuey import HUEY | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Flushes whole Huey storage or a build lock for a single course. Helpful if a task lock got stuck." | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('course_key', nargs='?', type=str, default="") | ||
|
||
def handle(self, *args, **options): | ||
# Check by arguments. | ||
if options["course_key"]: | ||
storage_key = HUEY.lock_task(f"build-{options['course_key']}")._key | ||
HUEY.delete(storage_key) | ||
self.stdout.write(f"Deleted lock for course with key {options['course_key']}") | ||
else: | ||
HUEY.flush() | ||
self.stdout.write(f"Flushed Huey storage") |