Skip to content

Commit

Permalink
Merge pull request #205 from olinlibrary/osteele/flake8-celery
Browse files Browse the repository at this point in the history
Fix flake8 errors in the top-level (celery) *.py files
  • Loading branch information
osteele committed May 3, 2018
2 parents 25a454d + 6aaed59 commit 7560950
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:

script:
- pipenv run coverage run --source abe -m unittest
- pipenv run flake8 abe
- pipenv run flake8 abe *.py

after_success:
- codecov
Expand Down
15 changes: 8 additions & 7 deletions celeryconfig.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from celery.schedules import crontab
from datetime import timedelta

'''
CELERY_RESULT_BACKEND = "mongodb"
CELERY_MONGODB_BACKEND_SETTINGS = {
"host": "127.0.0.1",
"port": 27017,
"database": "jobs",
"database": "jobs",
"taskmeta_collection": "stock_taskmeta_collection",
}
'''
#used to schedule tasks periodically and passing optional arguments
#Can be very useful. Celery does not seem to support scheduled task but only periodic

# used to schedule tasks periodically and passing optional arguments
# Can be very useful. Celery does not seem to support scheduled task but only periodic
CELERYBEAT_SCHEDULE = {
'refresh-every-2-hours': {
'task': 'tasks.refresh_calendar',
'schedule': timedelta(seconds=7200),
},
'refresh-every-minute': {
'task':'tasks.parse_email_icals',
'schedule': timedelta(seconds=60),
'task': 'tasks.parse_email_icals',
'schedule': timedelta(seconds=60),
}
}
}
25 changes: 14 additions & 11 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import logging

from celery import Celery
from abe.helper_functions.ics_helpers import update_ics_feed
from abe.helper_functions.email_helpers import scrape

from abe import database as db
import time
import logging
from abe.helper_functions.email_helpers import scrape
from abe.helper_functions.ics_helpers import update_ics_feed

#Specify mongodb host and datababse to connect to
# Specify mongodb host and datababse to connect to
BROKER_URL = db.return_uri()

celery = Celery('EOD_TASKS',broker=BROKER_URL)
celery = Celery('EOD_TASKS', broker=BROKER_URL)

#Loads settings for Backend to store results of jobs
# Loads settings for Backend to store results of jobs
celery.config_from_object('celeryconfig')


@celery.task
def refresh_calendar():
update_ics_feed()
return("did the stuff")
update_ics_feed()
logging.info("updated the ICS feed")


@celery.task
def parse_email_icals():
completed_events = scrape()
return("scraped the emails")
scrape()
logging.info("scraped the emails")

0 comments on commit 7560950

Please sign in to comment.