edx-celeryutils 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- celery_utils/__init__.py +7 -0
- celery_utils/admin.py +18 -0
- celery_utils/apps.py +13 -0
- celery_utils/logged_task.py +53 -0
- celery_utils/management/__init__.py +0 -0
- celery_utils/management/commands/__init__.py +0 -0
- celery_utils/management/commands/cleanup_resolved_tasks.py +60 -0
- celery_utils/management/commands/reapply_tasks.py +46 -0
- celery_utils/migrations/0001_initial.py +37 -0
- celery_utils/migrations/0002_chordable_django_backend.py +16 -0
- celery_utils/migrations/0003_rename_failedtask_task_name_exc_idx_failedtask_task_exc.py +18 -0
- celery_utils/migrations/__init__.py +0 -0
- celery_utils/models.py +64 -0
- celery_utils/persist_on_failure.py +61 -0
- celery_utils/tasks.py +19 -0
- edx_celeryutils-2.1.0.dist-info/METADATA +104 -0
- edx_celeryutils-2.1.0.dist-info/RECORD +21 -0
- edx_celeryutils-2.1.0.dist-info/WHEEL +5 -0
- edx_celeryutils-2.1.0.dist-info/licenses/AUTHORS +3 -0
- edx_celeryutils-2.1.0.dist-info/licenses/LICENSE.txt +201 -0
- edx_celeryutils-2.1.0.dist-info/top_level.txt +1 -0
celery_utils/__init__.py
ADDED
celery_utils/admin.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Admin site configuration.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from django.contrib import admin
|
|
6
|
+
|
|
7
|
+
from .models import FailedTask
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@admin.register(FailedTask)
|
|
11
|
+
class FailedTaskAdmin(admin.ModelAdmin):
|
|
12
|
+
"""
|
|
13
|
+
Customized admin for the FailedTask model.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
list_display = ['task_id', 'task_name', 'args', 'kwargs', 'created', 'datetime_resolved']
|
|
17
|
+
list_filter = ['task_name', 'created', 'datetime_resolved']
|
|
18
|
+
search_fields = ['task_name', 'task_id', 'args', 'kwargs']
|
celery_utils/apps.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Improved logging for celery tasks.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
from celery import Task
|
|
8
|
+
|
|
9
|
+
log = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# pylint: disable=abstract-method
|
|
13
|
+
class LoggedTask(Task):
|
|
14
|
+
"""
|
|
15
|
+
Task base class that emits a log statement when it gets submitted.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
abstract = True
|
|
19
|
+
|
|
20
|
+
def apply_async(self, args=None, kwargs=None, **options): # pylint: disable=arguments-differ
|
|
21
|
+
"""
|
|
22
|
+
Emit a log statement when the task is submitted.
|
|
23
|
+
"""
|
|
24
|
+
result = super().apply_async(args=args, kwargs=kwargs, **options)
|
|
25
|
+
log.info('Task {}[{}] submitted with arguments {}, {}'.format( # pylint: disable=consider-using-f-string
|
|
26
|
+
self.name,
|
|
27
|
+
result.id,
|
|
28
|
+
args,
|
|
29
|
+
kwargs
|
|
30
|
+
))
|
|
31
|
+
return result
|
|
32
|
+
|
|
33
|
+
def on_retry(self, exc, task_id, args, kwargs, einfo):
|
|
34
|
+
"""
|
|
35
|
+
Capture the exception that caused the task to be retried, if any.
|
|
36
|
+
"""
|
|
37
|
+
super().on_retry(exc, task_id, args, kwargs, einfo)
|
|
38
|
+
log.warning(
|
|
39
|
+
'[{}] retried due to {}'.format( # pylint: disable=consider-using-f-string
|
|
40
|
+
task_id, getattr(einfo, 'traceback', None)
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def on_failure(self, exc, task_id, args, kwargs, einfo):
|
|
45
|
+
"""
|
|
46
|
+
Capture the exception that caused the task to fail, if any.
|
|
47
|
+
"""
|
|
48
|
+
log.error(
|
|
49
|
+
'[{}] failed due to {}'.format( # pylint: disable=consider-using-f-string
|
|
50
|
+
task_id, getattr(einfo, 'traceback', None)
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
super().on_failure(exc, task_id, args, kwargs, einfo)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command to clean up resolved FailedTask records.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
import logging
|
|
7
|
+
from textwrap import dedent
|
|
8
|
+
|
|
9
|
+
from django.core.management.base import BaseCommand
|
|
10
|
+
from django.utils.timezone import now
|
|
11
|
+
|
|
12
|
+
from ...models import FailedTask
|
|
13
|
+
|
|
14
|
+
log = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Command(BaseCommand):
|
|
18
|
+
"""
|
|
19
|
+
Delete records of FailedTasks that have been resolved.
|
|
20
|
+
"""
|
|
21
|
+
help = dedent(__doc__).strip()
|
|
22
|
+
|
|
23
|
+
def add_arguments(self, parser):
|
|
24
|
+
"""
|
|
25
|
+
Add arguments to the command parser.
|
|
26
|
+
|
|
27
|
+
Uses argparse syntax. See documentation at
|
|
28
|
+
https://docs.python.org/3/library/argparse.html.
|
|
29
|
+
"""
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
'--dry-run',
|
|
32
|
+
action='store_true',
|
|
33
|
+
default=False,
|
|
34
|
+
help="Output what we're going to do, but don't actually do it."
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
'--task-name', '-t',
|
|
38
|
+
default=None,
|
|
39
|
+
help="Restrict cleanup to tasks matching the named task.",
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
'--age', '-a',
|
|
43
|
+
type=int,
|
|
44
|
+
default=30,
|
|
45
|
+
help="Only delete tasks that have been resolved for at least the specified number of days (default: 30)",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def handle(self, *args, **options):
|
|
49
|
+
tasks = FailedTask.objects.filter(datetime_resolved__lt=now() - timedelta(days=options['age']))
|
|
50
|
+
if options['task_name'] is not None:
|
|
51
|
+
tasks = tasks.filter(task_name=options['task_name'])
|
|
52
|
+
log.info('Cleaning up {} tasks'.format(tasks.count())) # pylint: disable=consider-using-f-string
|
|
53
|
+
if options['dry_run']:
|
|
54
|
+
log.info("Tasks to clean up:\n{}".format( # pylint: disable=consider-using-f-string
|
|
55
|
+
'\n '.join('{!r}, resolved {}'.format( # pylint: disable=consider-using-f-string
|
|
56
|
+
task, task.datetime_resolved) for task in tasks
|
|
57
|
+
)
|
|
58
|
+
))
|
|
59
|
+
else:
|
|
60
|
+
tasks.delete()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Reset persistent grades for learners.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from textwrap import dedent
|
|
7
|
+
|
|
8
|
+
from django.core.management.base import BaseCommand
|
|
9
|
+
|
|
10
|
+
from ...models import FailedTask
|
|
11
|
+
|
|
12
|
+
log = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Command(BaseCommand):
|
|
16
|
+
"""
|
|
17
|
+
Reapply tasks that failed previously.
|
|
18
|
+
"""
|
|
19
|
+
help = dedent(__doc__).strip()
|
|
20
|
+
|
|
21
|
+
def add_arguments(self, parser):
|
|
22
|
+
"""
|
|
23
|
+
Add arguments to the command parser.
|
|
24
|
+
|
|
25
|
+
Uses argparse syntax. See documentation at
|
|
26
|
+
https://docs.python.org/3/library/argparse.html.
|
|
27
|
+
"""
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
'--task-name', '-t',
|
|
30
|
+
action='store',
|
|
31
|
+
default=None,
|
|
32
|
+
help='Restrict reapplied tasks to those matching the given task-name.'
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def handle(self, *args, **options):
|
|
36
|
+
tasks = FailedTask.objects.filter(datetime_resolved=None)
|
|
37
|
+
if options['task_name'] is not None:
|
|
38
|
+
tasks = tasks.filter(task_name=options['task_name'])
|
|
39
|
+
log.info('Reapplying {} tasks'.format(tasks.count())) # pylint: disable=consider-using-f-string
|
|
40
|
+
log.debug('Reapplied tasks: {}'.format(list(tasks))) # pylint: disable=consider-using-f-string
|
|
41
|
+
seen_tasks = set()
|
|
42
|
+
for task in tasks:
|
|
43
|
+
if task.task_id in seen_tasks:
|
|
44
|
+
continue
|
|
45
|
+
seen_tasks.add(task.task_id)
|
|
46
|
+
task.reapply()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Generated by Django 1.10.5 on 2017-01-31 13:50
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
import django.utils.timezone
|
|
6
|
+
|
|
7
|
+
import jsonfield.fields
|
|
8
|
+
import model_utils.fields
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Migration(migrations.Migration):
|
|
12
|
+
|
|
13
|
+
initial = True
|
|
14
|
+
|
|
15
|
+
dependencies = [
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
operations = [
|
|
19
|
+
migrations.CreateModel(
|
|
20
|
+
name='FailedTask',
|
|
21
|
+
fields=[
|
|
22
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
23
|
+
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
|
|
24
|
+
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
|
|
25
|
+
('task_name', models.CharField(max_length=255)),
|
|
26
|
+
('task_id', models.CharField(db_index=True, max_length=255)),
|
|
27
|
+
('args', jsonfield.fields.JSONField(blank=True)),
|
|
28
|
+
('kwargs', jsonfield.fields.JSONField(blank=True)),
|
|
29
|
+
('exc', models.CharField(max_length=255)),
|
|
30
|
+
('datetime_resolved', models.DateTimeField(blank=True, db_index=True, default=None, null=True)),
|
|
31
|
+
],
|
|
32
|
+
),
|
|
33
|
+
migrations.AlterIndexTogether(
|
|
34
|
+
name='failedtask',
|
|
35
|
+
index_together={('task_name', 'exc')},
|
|
36
|
+
),
|
|
37
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from django.db import migrations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Migration(migrations.Migration):
|
|
5
|
+
"""
|
|
6
|
+
This migration used to have a model with a dependency on django-celery.
|
|
7
|
+
|
|
8
|
+
All the code in this migration has been removed along with the library.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
('celery_utils', '0001_initial'),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 4.2.11 on 2025-04-09 02:33
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('celery_utils', '0002_chordable_django_backend'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RenameIndex(
|
|
14
|
+
model_name='failedtask',
|
|
15
|
+
new_name='idx_failedtask_task_exc',
|
|
16
|
+
old_fields=('task_name', 'exc'),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
File without changes
|
celery_utils/models.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Database models for celery_utils.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
from django.db import models
|
|
8
|
+
|
|
9
|
+
from celery import current_app
|
|
10
|
+
from jsonfield import JSONField
|
|
11
|
+
from model_utils.models import TimeStampedModel
|
|
12
|
+
|
|
13
|
+
from celery_utils import tasks
|
|
14
|
+
|
|
15
|
+
log = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FailedTask(TimeStampedModel):
|
|
19
|
+
"""
|
|
20
|
+
Representation of tasks that have failed.
|
|
21
|
+
|
|
22
|
+
.. pii::
|
|
23
|
+
Stores arbitrary task parameters, which theoretically could include
|
|
24
|
+
email addresses, although as of May 2020 does not seem to.
|
|
25
|
+
Old tasks can be manually deleted in the Django administration UI.
|
|
26
|
+
.. pii_retirement: local_api
|
|
27
|
+
.. pii_types: other
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
task_name = models.CharField(max_length=255)
|
|
31
|
+
task_id = models.CharField(max_length=255, db_index=True)
|
|
32
|
+
args = JSONField(blank=True)
|
|
33
|
+
kwargs = JSONField(blank=True)
|
|
34
|
+
exc = models.CharField(max_length=255)
|
|
35
|
+
datetime_resolved = models.DateTimeField(blank=True, null=True, default=None, db_index=True)
|
|
36
|
+
|
|
37
|
+
class Meta:
|
|
38
|
+
"""
|
|
39
|
+
To specify any metadata for FailedTask model.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
indexes = [
|
|
43
|
+
models.Index(fields=['task_name', 'exc'], name='idx_failedtask_task_exc')
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
def reapply(self):
|
|
47
|
+
"""
|
|
48
|
+
Enqueue new celery task with the same arguments as the failed task.
|
|
49
|
+
"""
|
|
50
|
+
if self.datetime_resolved is not None:
|
|
51
|
+
raise TypeError(f'Cannot reapply a resolved task: {self}')
|
|
52
|
+
log.info('Reapplying failed task: {}'.format(self)) # pylint: disable=consider-using-f-string
|
|
53
|
+
original_task = current_app.tasks[self.task_name]
|
|
54
|
+
original_task.apply_async(
|
|
55
|
+
self.args,
|
|
56
|
+
self.kwargs,
|
|
57
|
+
task_id=self.task_id,
|
|
58
|
+
link=tasks.mark_resolved.si(self.task_id)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def __str__(self):
|
|
62
|
+
return f"FailedTask: {self.task_name}, " \
|
|
63
|
+
f"args={self.args}, kwargs={self.kwargs} " \
|
|
64
|
+
f"({'not resolved' if self.datetime_resolved is None else 'resolved'})"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Celery utility code for persistent tasks.
|
|
3
|
+
"""
|
|
4
|
+
# pylint: disable=abstract-method
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
from celery import Task
|
|
8
|
+
|
|
9
|
+
from .logged_task import LoggedTask
|
|
10
|
+
from .models import FailedTask
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PersistOnFailureTask(Task):
|
|
14
|
+
"""
|
|
15
|
+
Custom Celery Task base class that persists task data on failure.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
abstract = True
|
|
19
|
+
typing = False
|
|
20
|
+
|
|
21
|
+
def on_failure(self, exc, task_id, args, kwargs, einfo):
|
|
22
|
+
"""
|
|
23
|
+
If the task fails, persist a record of the task.
|
|
24
|
+
"""
|
|
25
|
+
if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists():
|
|
26
|
+
FailedTask.objects.create(
|
|
27
|
+
task_name=_truncate_to_field(FailedTask, 'task_name', self.name),
|
|
28
|
+
task_id=task_id, # Fixed length UUID: No need to truncate
|
|
29
|
+
args=args,
|
|
30
|
+
kwargs=kwargs,
|
|
31
|
+
# TODO: Remove ".replace(',', ''))" when python 3.5 support is dropped
|
|
32
|
+
exc=_truncate_to_field(FailedTask, 'exc', repr(exc).replace(',', '')),
|
|
33
|
+
)
|
|
34
|
+
super().on_failure(exc, task_id, args, kwargs, einfo)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class LoggedPersistOnFailureTask(PersistOnFailureTask, LoggedTask):
|
|
38
|
+
"""
|
|
39
|
+
Provides persistence features, as well as logging of task invocation.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
abstract = True
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _truncate_to_field(model, field_name, value):
|
|
46
|
+
"""
|
|
47
|
+
Shorten data to fit in the specified model field.
|
|
48
|
+
|
|
49
|
+
If the data were too big for the field, it would cause a failure to
|
|
50
|
+
insert, so we shorten it, truncating in the middle (because
|
|
51
|
+
valuable information often shows up at the end.
|
|
52
|
+
"""
|
|
53
|
+
field = model._meta.get_field(field_name) # pylint: disable=protected-access
|
|
54
|
+
if len(value) > field.max_length:
|
|
55
|
+
midpoint = field.max_length // 2
|
|
56
|
+
len_after_midpoint = field.max_length - midpoint
|
|
57
|
+
first = value[:midpoint]
|
|
58
|
+
sep = '...'
|
|
59
|
+
last = value[len(value) - len_after_midpoint + len(sep):]
|
|
60
|
+
value = sep.join([first, last])
|
|
61
|
+
return value
|
celery_utils/tasks.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Celery tasks that support the utils in this module.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from django.utils.timezone import now
|
|
6
|
+
|
|
7
|
+
from celery import shared_task
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@shared_task
|
|
11
|
+
def mark_resolved(task_id):
|
|
12
|
+
"""
|
|
13
|
+
Mark the specified task as resolved in the FailedTask table.
|
|
14
|
+
|
|
15
|
+
If more than one record exists with the specified task id, they will all be
|
|
16
|
+
marked resolved.
|
|
17
|
+
"""
|
|
18
|
+
from . import models # pylint: disable=import-outside-toplevel
|
|
19
|
+
models.FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).update(datetime_resolved=now())
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edx-celeryutils
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Code to support working with celery
|
|
5
|
+
Author-email: Open edX Project <oscm@openedx.org>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/openedx/edx-celeryutils
|
|
8
|
+
Project-URL: Repository, https://github.com/openedx/edx-celeryutils
|
|
9
|
+
Keywords: Django,edx
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Framework :: Django :: 4.2
|
|
13
|
+
Classifier: Framework :: Django :: 5.2
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Description-Content-Type: text/x-rst
|
|
20
|
+
License-File: LICENSE.txt
|
|
21
|
+
License-File: AUTHORS
|
|
22
|
+
Requires-Dist: celery<6.0
|
|
23
|
+
Requires-Dist: Django
|
|
24
|
+
Requires-Dist: django-model-utils
|
|
25
|
+
Requires-Dist: jsonfield
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
edx-celeryutils
|
|
29
|
+
=============================
|
|
30
|
+
|
|
31
|
+
.. image:: https://img.shields.io/pypi/v/edx-celeryutils.svg
|
|
32
|
+
:target: https://pypi.python.org/pypi/edx-celeryutils/
|
|
33
|
+
:alt: PyPI
|
|
34
|
+
|
|
35
|
+
.. image:: https://github.com/openedx/edx-celeryutils/workflows/Python%20CI/badge.svg?branch=master
|
|
36
|
+
:target: https://github.com/openedx/edx-celeryutils/actions?query=workflow%3A%22Python+CI%22
|
|
37
|
+
:alt: CI
|
|
38
|
+
|
|
39
|
+
.. image:: http://codecov.io/github/edx/edx-celeryutils/coverage.svg?branch=master
|
|
40
|
+
:target: http://codecov.io/github/edx/edx-celeryutils?branch=master
|
|
41
|
+
:alt: Codecov
|
|
42
|
+
|
|
43
|
+
.. image:: http://edx-celeryutils.readthedocs.io/en/latest/?badge=latest
|
|
44
|
+
:target: http://edx-celeryutils.readthedocs.io/en/latest/
|
|
45
|
+
:alt: Documentation
|
|
46
|
+
|
|
47
|
+
.. image:: https://img.shields.io/pypi/pyversions/edx-celeryutils.svg
|
|
48
|
+
:target: https://pypi.python.org/pypi/edx-celeryutils/
|
|
49
|
+
:alt: Supported Python versions
|
|
50
|
+
|
|
51
|
+
.. image:: https://img.shields.io/github/license/edx/edx-celeryutils.svg
|
|
52
|
+
:target: https://github.com/openedx/edx-celeryutils/blob/master/LICENSE.txt
|
|
53
|
+
:alt: License
|
|
54
|
+
|
|
55
|
+
Code to support working with Celery, a distributed task queue.
|
|
56
|
+
|
|
57
|
+
Overview (please modify)
|
|
58
|
+
------------------------
|
|
59
|
+
|
|
60
|
+
This package contains utilities to wrap tasks with logging and to
|
|
61
|
+
persist them if they fail.
|
|
62
|
+
|
|
63
|
+
It also supports Django administration for searching and deleting
|
|
64
|
+
failed tasks, and management commands for rerunning failed tasks and
|
|
65
|
+
deleting old ones.
|
|
66
|
+
|
|
67
|
+
Documentation
|
|
68
|
+
-------------
|
|
69
|
+
|
|
70
|
+
(TODO: `Set up documentation <https://openedx.atlassian.net/wiki/spaces/DOC/pages/21627535/Publish+Documentation+on+Read+the+Docs>`_)
|
|
71
|
+
|
|
72
|
+
Publishing a Release
|
|
73
|
+
--------------------
|
|
74
|
+
|
|
75
|
+
Merges to master are released automatically by python-semantic-release, which picks the version from the
|
|
76
|
+
conventional commit types. Release notes are on the `GitHub Releases <https://github.com/openedx/edx-celeryutils/releases>`_ page.
|
|
77
|
+
|
|
78
|
+
License
|
|
79
|
+
-------
|
|
80
|
+
|
|
81
|
+
The code in this repository is licensed under the Apache 2.0 unless
|
|
82
|
+
otherwise noted.
|
|
83
|
+
|
|
84
|
+
Please see ``LICENSE.txt`` for details.
|
|
85
|
+
|
|
86
|
+
How To Contribute
|
|
87
|
+
-----------------
|
|
88
|
+
|
|
89
|
+
Contributions are very welcome.
|
|
90
|
+
|
|
91
|
+
Please read `How To Contribute <https://github.com/openedx/.github/blob/master/CONTRIBUTING.md>`_ for details.
|
|
92
|
+
|
|
93
|
+
Reporting Security Issues
|
|
94
|
+
-------------------------
|
|
95
|
+
|
|
96
|
+
Please do not report security issues in public. Please email security@openedx.org.
|
|
97
|
+
|
|
98
|
+
Getting Help
|
|
99
|
+
------------
|
|
100
|
+
|
|
101
|
+
Have a question about this repository, or about Open edX in general? Please
|
|
102
|
+
refer to this `list of resources`_ if you need any assistance.
|
|
103
|
+
|
|
104
|
+
.. _list of resources: https://open.edx.org/getting-help
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
celery_utils/__init__.py,sha256=-g3yVRgYry76iaOo2KwaA9o7P-YleOeHUzffjDJAeE4,127
|
|
2
|
+
celery_utils/admin.py,sha256=fQPVUy7_N1tesbljecenGSiBOjCMhbOGW-BjyJRorY8,456
|
|
3
|
+
celery_utils/apps.py,sha256=w9WkNDX4DPCszoCkeDdRqP5cLUrZtJ5yIcrkCx3-2ac,231
|
|
4
|
+
celery_utils/logged_task.py,sha256=eRdLHq0-k0qCGxzxHHAEBJoGoVT5gBql97b6r7yOPsU,1586
|
|
5
|
+
celery_utils/models.py,sha256=QNfMdCiexqbz2QM-XGLX0SbS1Uwgz0nexlwFMiFZ6PQ,1991
|
|
6
|
+
celery_utils/persist_on_failure.py,sha256=CW2ZSc3GuPn3FM_h_vK1vqrHgBBqrdHXbiPUfgySLME,1965
|
|
7
|
+
celery_utils/tasks.py,sha256=CQHohMzimaO8xzJ880nDHxm4iuS--xog40u0ZGsSq9M,535
|
|
8
|
+
celery_utils/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
celery_utils/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
celery_utils/management/commands/cleanup_resolved_tasks.py,sha256=zrnCgCjLcJu53QArzrlRj95-mvyiAEMTG4HTecFc-es,1988
|
|
11
|
+
celery_utils/management/commands/reapply_tasks.py,sha256=IVCEdhuKNMSE2Kq3SsEi0Qv0pXp1_7voOOsJegr2lyk,1377
|
|
12
|
+
celery_utils/migrations/0001_initial.py,sha256=IoDDu7CMykSuCOirVjaFEGg6ois3quEWYII4bSeE9Es,1382
|
|
13
|
+
celery_utils/migrations/0002_chordable_django_backend.py,sha256=A2omQrsnVWPTw87UoTHXnhc9jXufnoPfpvRFPayH21k,339
|
|
14
|
+
celery_utils/migrations/0003_rename_failedtask_task_name_exc_idx_failedtask_task_exc.py,sha256=UKyvV-TJwVNoCmSs62G-hteM4dmxq6g32CI4p2jLXhA,410
|
|
15
|
+
celery_utils/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
edx_celeryutils-2.1.0.dist-info/licenses/AUTHORS,sha256=-gigXZBDBf_jJmA0J4qVLLxW0h50uzo6dlPnudvCnPs,101
|
|
17
|
+
edx_celeryutils-2.1.0.dist-info/licenses/LICENSE.txt,sha256=llpjqB2aL761-QlpVNq7SWkPnf_NrJgl9nWyXIByUqI,10702
|
|
18
|
+
edx_celeryutils-2.1.0.dist-info/METADATA,sha256=_jRfyt-OpO-nWlgolRZlUWwszK8FVA9Szd1jwcMLayU,3478
|
|
19
|
+
edx_celeryutils-2.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
20
|
+
edx_celeryutils-2.1.0.dist-info/top_level.txt,sha256=1B4nzOJQYb4l_8RzUl6HQOBt8km8X1aDggtEWxFogXk,13
|
|
21
|
+
edx_celeryutils-2.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
celery_utils
|