From 44c5ff3552b7442706aa8eb415a0362283c0428a Mon Sep 17 00:00:00 2001 From: Atalya Alon Date: Thu, 16 Apr 2020 15:20:00 +0300 Subject: [PATCH] remove celery --- .travis.yml | 1 - Procfile | 1 - anyway/clusters_calculator.py | 2 -- anyway/task_queue.py | 39 ----------------------------------- requirements.txt | 1 - 5 files changed, 44 deletions(-) delete mode 100644 anyway/task_queue.py diff --git a/.travis.yml b/.travis.yml index 85d98ceaf..8de06b28d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,6 @@ install: before_script: - psql -c 'create database anyway;' -U postgres - alembic upgrade head - - celery worker -A anyway.clusters_calculator -D script: - pylint -j $(nproc) anyway tests main.py diff --git a/Procfile b/Procfile index 94b63fad4..e217500b2 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1 @@ web: NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program gunicorn anyway:app -worker: celery worker -A anyway.clusters_calculator diff --git a/anyway/clusters_calculator.py b/anyway/clusters_calculator.py index 5b31f8fbe..53931ac4b 100644 --- a/anyway/clusters_calculator.py +++ b/anyway/clusters_calculator.py @@ -2,9 +2,7 @@ import time from .models import AccidentMarker from .pymapcluster import calculate_clusters -from .task_queue import task_queue -@task_queue.task def retrieve_clusters(**kwargs): start_time = time.time() result = AccidentMarker.bounding_box_query(is_thin=True, **kwargs) diff --git a/anyway/task_queue.py b/anyway/task_queue.py deleted file mode 100644 index bb61336e1..000000000 --- a/anyway/task_queue.py +++ /dev/null @@ -1,39 +0,0 @@ -import itertools -import os - -if os.environ.get("ANYWAY_DISABLE_CELERY"): - from functools import partial - - - class MockTaskQueue(object): - @staticmethod - def task(f): - f.delay = f - return f - - - task_queue = MockTaskQueue - - task_signature = partial - - - def map_task(task, candidates): - return list(itertools.chain.from_iterable(task(candidate) for candidate in candidates)) - -else: - from celery import Celery, group - - task_queue = Celery('tasks', - backend=os.environ.get('CELERY_BACKEND_URL', 'rpc://'), - broker=os.environ.get('CELERY_BROKER_URL', 'amqp://guest@localhost//')) - - - def task_signature(task, *args, **kwargs): - return task.s(*args, **kwargs) - - - def map_task(task, candidates): - job = group([task.clone([candidate]) for candidate in candidates]) - result = job.apply_async() - result.join() - return list(itertools.chain.from_iterable(result.get())) diff --git a/requirements.txt b/requirements.txt index e02e3de50..859c6f88a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,7 +29,6 @@ requests setuptools click six -celery[redis] openpyxl enum34 feedparser