Commit 851f355c authored by 谢祁峰's avatar 谢祁峰

t Merge branch 'master' of git.wanmeizhensuo.com:alpha/physical into test

parents c242ff22 f938003c
...@@ -5,4 +5,4 @@ crontab: ...@@ -5,4 +5,4 @@ crontab:
======= =======
>>>>>>> fe8ae25876e5baba8581e3a79f5440c3f7f21dca >>>>>>> fe8ae25876e5baba8581e3a79f5440c3f7f21dca
celery: celery:
celery -A physical worker -c 1 -Q vest -l debug celery -A physical worker -c 1 -Q tapir-alpha -l debug --max-tasks-per-child == 500
...@@ -29,8 +29,8 @@ def get_rand_time(hourlow=0, hourup=13, minutelow=0, minuteup=60): ...@@ -29,8 +29,8 @@ def get_rand_time(hourlow=0, hourup=13, minutelow=0, minuteup=60):
# todo redis会自动给加8个小时,所以这边先写死减少8小时 # todo redis会自动给加8个小时,所以这边先写死减少8小时
now_time = NOW + timedelta(hours=hours, minutes=minutes) - timedelta(hours=8) now_time = NOW + timedelta(hours=hours, minutes=minutes) - timedelta(hours=8)
time = eta_2_push_time(now_time.strftime("%Y-%m-%d %H:%M:%S")) time = eta_2_push_time(now_time.strftime("%Y-%m-%d %H:%M:%S"))
print(datetime.fromtimestamp(time)) print(datetime.fromtimestamp(time, pytz.timezone('Asia/Shanghai')))
return datetime.fromtimestamp(time) return datetime.fromtimestamp(time, pytz.timezone('Asia/Shanghai'))
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -13,6 +13,14 @@ app = Celery('physical') ...@@ -13,6 +13,14 @@ app = Celery('physical')
# - 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.config_from_object('django.conf:settings', namespace='CELERY')
app.conf.ONCE = {
'backend': 'celery_once.backends.Redis',
'settings': {
'url': settings.CELERY_BROKER_URL,
'default_timeout': 60 * 60
}
}
# Load task modules from all registered Django app configs. # Load task modules from all registered Django app configs.
app.autodiscover_tasks() app.autodiscover_tasks()
......
...@@ -9,8 +9,6 @@ class CeleryTaskRouter(object): ...@@ -9,8 +9,6 @@ class CeleryTaskRouter(object):
queue_task_map = { queue_task_map = {
"tapir-alpha": [ "tapir-alpha": [
'injection.data_sync.tasks.write_to_es', 'injection.data_sync.tasks.write_to_es',
],
"vest": [
'vest.request.auto_request.click', 'vest.request.auto_request.click',
'vest.request.auto_request.reply', 'vest.request.auto_request.reply',
'vest.request.auto_request.follow', 'vest.request.auto_request.follow',
......
...@@ -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 @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True, 'unlock_before_run': 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 @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True, 'unlock_before_run': 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 @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True, 'unlock_before_run': 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 @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True, 'unlock_before_run': 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 @shared_task(retry_kwargs={'max_retries': 0}, base=QueueOnce, once={'graceful': True, 'unlock_before_run': 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