Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
celery-haystack-ng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
celery-haystack-ng
Commits
b286c57e
Verified
Commit
b286c57e
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Make task API compatible with Celery 4 and 5
parent
1361998e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.rst
+1
-1
1 addition, 1 deletion
README.rst
celery_haystack/tasks.py
+10
-3
10 additions, 3 deletions
celery_haystack/tasks.py
with
11 additions
and
4 deletions
README.rst
+
1
−
1
View file @
b286c57e
...
...
@@ -12,7 +12,7 @@ Requirements
* Django 1.8+
* Haystack_ `2.X`_
* Celery_
3
.X
* Celery_
5
.X
You also need to install your choice of one of the supported search engines
for Haystack and one of the supported backends for Celery.
...
...
This diff is collapsed.
Click to expand it.
celery_haystack/tasks.py
+
10
−
3
View file @
b286c57e
...
...
@@ -7,13 +7,14 @@ from .conf import settings
from
haystack
import
connections
,
connection_router
from
haystack.exceptions
import
NotHandled
as
IndexNotFoundException
from
celery
import
Task
# noqa
from
celery
import
current_app
# noqa
from
celery.utils.log
import
get_task_logger
logger
=
get_task_logger
(
__name__
)
class
CeleryHaystackSignalHandler
(
Task
):
class
CeleryHaystackSignalHandler
(
current_app
.
Task
):
name
=
"
haystack_signal_handler
"
using
=
settings
.
CELERY_HAYSTACK_DEFAULT_ALIAS
max_retries
=
settings
.
CELERY_HAYSTACK_MAX_RETRIES
default_retry_delay
=
settings
.
CELERY_HAYSTACK_RETRY_DELAY
...
...
@@ -134,11 +135,13 @@ class CeleryHaystackSignalHandler(Task):
raise
ValueError
(
"
Unrecognized action %s
"
%
action
)
class
CeleryHaystackUpdateIndex
(
Task
):
class
CeleryHaystackUpdateIndex
(
current_app
.
Task
):
"""
A celery task class to be used to call the update_index management
command from Celery.
"""
name
=
"
haystack_update_index
"
def
run
(
self
,
apps
=
None
,
**
kwargs
):
defaults
=
{
'
batchsize
'
:
settings
.
CELERY_HAYSTACK_COMMAND_BATCH_SIZE
,
...
...
@@ -155,3 +158,7 @@ class CeleryHaystackUpdateIndex(Task):
logger
.
info
(
"
Starting update index
"
)
call_command
(
'
update_index
'
,
*
apps
,
**
defaults
)
logger
.
info
(
"
Finishing update index
"
)
current_app
.
tasks
.
register
(
CeleryHaystackSignalHandler
)
current_app
.
tasks
.
register
(
CeleryHaystackUpdateIndex
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment