Changeset 12 in feed2telegram


Ignore:
Timestamp:
08/24/18 12:41:40 (3 years ago)
Author:
cheese
Message:

#1 change feedparser.parse to requests for timeout

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/feed2telegram.py

    r11 r12  
    120120
    121121    def get(self):
    122         self.feed = feedparser.parse(self.url)# , etag=self.etag, modified=self.modified)
     122        try:
     123            resp = requests.get(self.url, timeout=10.0)
     124        except requests.ReadTimeout as e:
     125            raise
     126
     127        # self.feed = feedparser.parse(self.url)# , etag=self.etag, modified=self.modified)
     128        self.feed = feedparser.parse(resp.content)
    123129
    124130        try:
     
    187193        self.last_modified = self.feed.modified
    188194        feed = self.feed.get()
    189        
     195
    190196        for entry in self.get_entries(feed.entries):
    191197            if self.stop_event.is_set():
    192198                break
    193        
     199
    194200            if not self.isSendingEntry(entry):
    195201                continue
    196        
     202
    197203            message = self.get_message(entry)
    198204            self.telegram.sendMessage(message)
    199        
     205
    200206        self.feed.save()
    201207
  • trunk/implements/hikarinoakariost_feeder.py

    r10 r12  
    1010              chat_id,
    1111              lambda entry: entry['link'],
    12               callback_get_entries=lambda entries: reversed(entries),
    1312              continue_on_error=True,
    1413             ).start()
Note: See TracChangeset for help on using the changeset viewer.