예제 #1
0
파일: media.py 프로젝트: yangzxstar/reddit
    def process_link(msg):
        fname = msg.body
        link = Link._by_fullname(msg.body, data=True)

        try:
            TimeoutFunction(_set_media, 30)(link, use_cache=True)
        except TimeoutFunctionException:
            print "Timed out on %s" % fname
        except KeyboardInterrupt:
            raise
        except:
            print "Error fetching %s" % fname
            print traceback.format_exc()
예제 #2
0
    def process_link(msg):
        def _process_link(fname):
            link = Link._by_fullname(fname, data=True)
            set_media(link)

        fname = msg.body
        try:
            TimeoutFunction(_process_link, 30)(fname)
        except TimeoutFunctionException:
            print "Timed out on %s" % fname
        except KeyboardInterrupt:
            raise
        except:
            print "Error fetching %s" % fname
            print traceback.format_exc()
예제 #3
0
    def _handle_q(msg):
        d = json.loads(msg.body)

        try:
            fn = TimeoutFunction(parse_embeds, 10)
            liveupdate = fn(d['event_id'], d['liveupdate_id'])
        except TimeoutFunctionException:
            g.log.warning("Timed out on %s::%s", d["event_id"],
                          d["liveupdate_id"])
            return
        except Exception as e:
            g.log.warning("Failed to scrape %s::%s: %r", d["event_id"],
                          d["liveupdate_id"], e)
            return

        payload = {
            "liveupdate_id": "LiveUpdate_" + d['liveupdate_id'],
            "media_embeds": liveupdate.embeds,
            "mobile_embeds": liveupdate.mobile_embeds,
        }
        send_event_broadcast(d['event_id'],
                             type="embeds_ready",
                             payload=payload)