-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from olinlibrary/osteele/flake8-celery
Fix flake8 errors in the top-level (celery) *.py files
- Loading branch information
Showing
3 changed files
with
23 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |