Skip to content

Commit

Permalink
Successfully setup celery
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnytarawade committed Aug 9, 2022
1 parent e424375 commit 7140edb
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 26 deletions.
Binary file added dump.rdb
Binary file not shown.
10 changes: 5 additions & 5 deletions faang_gsoc/graphql_api/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class Query(OrganismSchema,ExperimentSchema, AnalysisSchema, ArticleSchema, Data

def resolve_hello(parent,info):
# res = graphql_task.apply_async(queue='graphql_q')
res2 = resolve_all('organism')
# res2 = resolve_all('organism')
# print(res2)
# res = graphql_task.apply_async(queue='graphql_api')
# print(res)
return res2
# return 'Hola'
res = graphql_task.apply_async(queue='graphql_api')
print(res)
return res.id
return 'Hola'

schema = Schema(query=Query)
5 changes: 3 additions & 2 deletions faang_gsoc/graphql_api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from celery.signals import after_setup_logger
import logging
import os.path
import time

APP_PATH = os.path.dirname(os.path.realpath(__file__))
logger = get_task_logger(__name__)
Expand All @@ -29,6 +30,6 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):

@app.task(base=LogErrorsTask)
def graphql_task():
# time.sleep(5)
time.sleep(20)
print('I am graphql Task')
return 'Hi!!!'
return {'werk':'it'}
2 changes: 2 additions & 0 deletions faang_gsoc/graphql_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from graphene_django.views import GraphQLView
from decouple import config
from django.views.decorators.csrf import csrf_exempt
from . import views

DEBUG = config('DEBUG',default=False)

urlpatterns = [
# TODO remove csrf_exempt in prod : https://stackoverflow.com/questions/51764452/403-by-graphene-django-dont-use-csrf-exempt
path("", csrf_exempt(GraphQLView.as_view(graphiql=DEBUG))),
path("tasks/<str:task_id>",views.get_task_details)

]
7 changes: 7 additions & 0 deletions faang_gsoc/graphql_api/views.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# Create your views here.
from celery.result import AsyncResult
from django.http import JsonResponse

def get_task_details(request,task_id):
res = AsyncResult(task_id)
print(res.result)
return JsonResponse({'res':res.result})
107 changes: 88 additions & 19 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,89 @@
daphne==3.0.0
celery==4.4.7
python-decouple==3.1
Django==3.2.4
channels==3.0.1
django-cors-headers==3.5.0
requests==2.24.0
xlrd==1.2.0
aiohttp==3.7.2
lxml==4.6.1
xlsxwriter==1.3.7
redis==3.5.3
channels-redis
elasticsearch==7.10.0
pandas==1.1.4
psycopg2-binary
djangorestframework==3.12.2
aiohttp==3.8.1
aioredis==1.3.1
aiosignal==1.2.0
amqp==5.1.1
aniso8601==7.0.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==22.1.0
autobahn==22.7.1
Automat==20.2.0
billiard==3.6.4.0
celery==5.2.7
certifi==2022.6.15
cffi==1.15.1
channels==3.0.5
channels-redis==3.4.1
charset-normalizer==2.1.0
click==8.1.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
constantly==15.1.0
cryptography==37.0.4
daphne==3.0.2
Deprecated==1.2.13
Django==3.2.15
django-channels==0.7.0
django-channels-graphql-ws==0.9.1
django-cors-headers==3.13.0
django-elasticsearch-dsl==7.2.2
django-elasticsearch-dsl-drf==0.22.5
django-nine==0.2.5
django-redis==5.2.0
django-rest-framework==0.1.0
djangorestframework==3.13.1
djangorestframework-jwt==1.11.0
drf-yasg==1.20.0
flower==0.9.5
elasticsearch==7.17.4
elasticsearch-dsl==7.4.0
flower==1.2.0
frozenlist==1.3.1
graphene==2.1.9
graphene-django==2.15.0
graphql-core==2.3.2
graphql-relay==2.0.1
graphql-ws==0.4.4
hiredis==2.0.0
humanize==4.3.0
hyperlink==21.0.0
idna==3.3
incremental==21.3.0
kombu==5.2.4
lxml==4.9.1
msgpack==1.0.4
multidict==6.0.2
oauthlib==3.2.0
packaging==21.3
prometheus-client==0.14.1
promise==2.3
prompt-toolkit==3.0.30
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
PyJWT==1.7.1
pyOpenSSL==22.0.0
pyparsing==3.0.9
python-dateutil==2.8.2
python-decouple==3.6
pytz==2022.1
redis==4.3.4
requests==2.28.1
requests-oauthlib==1.3.1
Rx==1.6.1
service-identity==21.1.0
singledispatch==3.7.0
six==1.16.0
sqlparse==0.4.2
text-unidecode==1.3
tornado==6.2
Twisted==22.4.0
txaio==22.2.1
typing_extensions==4.3.0
urllib3==1.26.11
vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.1
xlrd==2.0.1
XlsxWriter==3.0.3
yarl==1.8.1
zope.interface==5.4.0

0 comments on commit 7140edb

Please sign in to comment.