Permalink
Browse files

Updated ical and talks_cam to work async with Celery.

  • Loading branch information...
1 parent f0bb9c5 commit 70c230d2d0d791f40540c404768f552b8fbbe483 @davbo davbo committed Mar 23, 2012
Showing with 6 additions and 19 deletions.
  1. +3 −9 molly/apps/feeds/providers/ical.py
  2. +3 −10 molly/apps/feeds/providers/talks_cam.py
@@ -1,7 +1,5 @@
from datetime import datetime, timedelta
import urllib2
-import random
-import traceback
import logging
from icalendar import Calendar
from icalendar.prop import vDatetime, vDate, vText
@@ -31,17 +29,13 @@ def import_data(self, **metadata):
"""
Pulls iCal feeds
"""
-
from molly.apps.feeds.models import Feed
for feed in Feed.objects.filter(provider=self.class_path):
- logger.info("Importing %s\n" % feed.title)
- try:
- self.import_feed(feed)
- except Exception, e:
- logger.warn("Error importing feed %r" % feed.title,
- exc_info=True, extra={'url': feed.rss_url})
+ logger.debug("Importing: %s - %s" % (feed.title, feed.rss_url))
+ self.import_feed.apply_async(args=(feed,))
return metadata
+ @task()
def import_feed(self, feed):
from molly.apps.feeds.models import Item, vCard
@@ -1,8 +1,6 @@
from datetime import datetime, timedelta
from lxml import etree
import urllib2
-import random
-import traceback
import logging
import socket
socket.setdefaulttimeout(5)
@@ -25,18 +23,13 @@ def import_data(self, **metadata):
"""
Pulls TalksCam feeds
"""
-
from molly.apps.feeds.models import Feed
for feed in Feed.objects.filter(provider=self.class_path):
- logger.info("Importing %s\n" % feed.title)
- try:
- self.import_feed(feed)
- except Exception, e:
- logger.warn("Error importing feed %r" % feed.title,
- exc_info=True, extra={'url': feed.rss_url})
-
+ logger.debug("Importing: %s - %s" % (feed.title, feed.rss_url))
+ self.import_feed.apply_async(args=(feed,))
return metadata
+ @task()
def import_feed(self, feed):
from molly.apps.feeds.models import Item, vCard

0 comments on commit 70c230d

Please sign in to comment.