Commit 912ec075 authored by 吴升宇's avatar 吴升宇

Merge branch 'wsy3' into 'test'

add celery once

See merge request !538
parents 6c7edda5 c2bbc63f
...@@ -12,7 +12,7 @@ app = Celery('physical') ...@@ -12,7 +12,7 @@ app = Celery('physical')
# the configuration object to child processes. # the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys # - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix. # should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY') app.conf.ONCE.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs. # Load task modules from all registered Django app configs.
app.autodiscover_tasks() app.autodiscover_tasks()
......
...@@ -14,6 +14,7 @@ gevent==1.3.7 ...@@ -14,6 +14,7 @@ gevent==1.3.7
pypinyin==0.34.1 pypinyin==0.34.1
numpy==1.16.2 numpy==1.16.2
lz4==2.1.6 lz4==2.1.6
celery_once==3.0.1
git+ssh://git@git.wanmeizhensuo.com/backend/gm-rpcd.git@master git+ssh://git@git.wanmeizhensuo.com/backend/gm-rpcd.git@master
git+ssh://git@git.wanmeizhensuo.com/backend/helios.git@master git+ssh://git@git.wanmeizhensuo.com/backend/helios.git@master
......
...@@ -8,6 +8,7 @@ import json ...@@ -8,6 +8,7 @@ import json
import redis import redis
import smtplib import smtplib
from celery import shared_task from celery import shared_task
from celery_once import QueueOnce
from libs.cache import redis_client from libs.cache import redis_client
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.utils import formataddr from email.utils import formataddr
...@@ -114,7 +115,7 @@ def logins(user_id): ...@@ -114,7 +115,7 @@ def logins(user_id):
return None return None
@shared_task(retry_kwargs={'max_retries': 0}) @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True})
def click(cookies_get, id): def click(cookies_get, id):
# 点赞 # 点赞
try: try:
...@@ -148,7 +149,7 @@ def click(cookies_get, id): ...@@ -148,7 +149,7 @@ def click(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
@shared_task(retry_kwargs={'max_retries': 0}) @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True})
def reply(cookies_get, id, content): def reply(cookies_get, id, content):
try: try:
post_dict = { post_dict = {
...@@ -272,7 +273,7 @@ def get_comments(): ...@@ -272,7 +273,7 @@ def get_comments():
return None return None
@shared_task(retry_kwargs={'max_retries': 0}) @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True})
def follow(cookies_get, id): def follow(cookies_get, id):
try: try:
post_dict = { post_dict = {
...@@ -438,7 +439,7 @@ def set_reply_to_redis(): ...@@ -438,7 +439,7 @@ def set_reply_to_redis():
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
@shared_task(retry_kwargs={'max_retries': 0}) @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True})
def reply2(cookies_get, id, content, replied_id): def reply2(cookies_get, id, content, replied_id):
try: try:
post_dict = { post_dict = {
...@@ -459,7 +460,7 @@ def reply2(cookies_get, id, content, replied_id): ...@@ -459,7 +460,7 @@ def reply2(cookies_get, id, content, replied_id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
@shared_task(retry_kwargs={'max_retries': 0}) @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True})
def pictorial_reply(cookies_get, id, content): def pictorial_reply(cookies_get, id, content):
try: try:
post_dict = { post_dict = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment