149fb49b by 周伟奇

celery init

1 parent 5af23667
...@@ -5,6 +5,7 @@ appdirs==1.4.4 ...@@ -5,6 +5,7 @@ appdirs==1.4.4
5 async-timeout==3.0.1 5 async-timeout==3.0.1
6 attrs==19.3.0 6 attrs==19.3.0
7 cached-property==1.5.1 7 cached-property==1.5.1
8 celery==4.4.2
8 certifi==2020.6.20 9 certifi==2020.6.20
9 chardet==3.0.4 10 chardet==3.0.4
10 defusedxml==0.6.0 11 defusedxml==0.6.0
......
...@@ -19,6 +19,7 @@ from .models import UploadDocRecords, DocStatus, PriorityApplication, GCAPRecord ...@@ -19,6 +19,7 @@ from .models import UploadDocRecords, DocStatus, PriorityApplication, GCAPRecord
19 from .mixins import DocHandler 19 from .mixins import DocHandler
20 from . import consts 20 from . import consts
21 from apps.account.authentication import OAuth2AuthenticationWithUser 21 from apps.account.authentication import OAuth2AuthenticationWithUser
22 from celery_compare.tasks import test
22 23
23 24
24 # restframework将request.body封装至request.data, webargs从request.data中获取参数 25 # restframework将request.body封装至request.data, webargs从request.data中获取参数
...@@ -312,6 +313,7 @@ class CompareView(GenericView): ...@@ -312,6 +313,7 @@ class CompareView(GenericView):
312 @use_args(compare_args, location='data') 313 @use_args(compare_args, location='data')
313 def post(self, request, args): 314 def post(self, request, args):
314 self.running_log.info('in') 315 self.running_log.info('in')
316 test.apply_async((args, ), queue='queue_compare')
315 return response.ok() 317 return response.ok()
316 318
317 post.openapi_doc = ''' 319 post.openapi_doc = '''
......
1 from celery import Celery
2 from settings import conf
3
4 broker = conf.CELERY_BROKER_URL
5
6 app = Celery('celery_compare', broker=broker, include=['celery_compare.tasks'])
7
8 app.conf.update(worker_max_tasks_per_child=5, timezone='Asia/Shanghai')
...\ No newline at end of file ...\ No newline at end of file
1 from . import app
2
3
4 @app.task
5 def test(info):
6 print(info)
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!