aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-01-19 21:59:24 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-01-19 21:59:24 +0100
commita9df02d807da6622bd15d9c10d6a11866335eeeb (patch)
treee60266514e68736b69bd6e6c408ee51eb097cc35 /pyaggr3g470r
parentOnly get the URL with requests if the string 'feedproxy' is found in the netl... (diff)
downloadnewspipe-a9df02d807da6622bd15d9c10d6a11866335eeeb.tar.gz
newspipe-a9df02d807da6622bd15d9c10d6a11866335eeeb.tar.bz2
newspipe-a9df02d807da6622bd15d9c10d6a11866335eeeb.zip
The MongoEngine object is saved after all threads are done.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/feedgetter.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py
index da28663c..cc9f8aa4 100644
--- a/pyaggr3g470r/feedgetter.py
+++ b/pyaggr3g470r/feedgetter.py
@@ -96,6 +96,8 @@ class FeedGetter(object):
for th in list_of_threads:
th.join()
+ self.user.save()
+
def process(self, feed):
"""
Retrieves articles form the feed and add them to the database.
@@ -111,10 +113,11 @@ class FeedGetter(object):
if "feedproxy" in urlparse(nice_url).netloc:
try:
# resolves URL behind proxies (like feedproxy.google.com)
- r = requests.get(article.link, timeout=10.0, proxies=self.proxies)
+ r = requests.get(article.link, timeout=5.0, proxies=self.proxies)
nice_url = r.url.encode("utf-8")
except Timeout:
pyaggr3g470r_log.warning("Timeout when getting the real URL of %s." % (article.link,))
+ print "Time out"
continue
except Exception as e:
pyaggr3g470r_log.warning("Unable to get the real URL of %s. Error: %s" % (article.link, str(e)))
@@ -187,7 +190,7 @@ class FeedGetter(object):
# add the articles to the list of articles for the current feed
feed.articles.extend(articles)
feed.articles = sorted(feed.articles, key=lambda t: t.date, reverse=True)
- self.user.save()
+ return True
if __name__ == "__main__":
bgstack15