Exemplo n.º 1
0
 def __do_fetch(self, url, cb, errcb, cookies, data, nocache, cache_time):
     self.__logger.debug("in thread fetch of %s (%s)" % (url, data))
     try:
         (fname, fdata) = httpcache.load(url, cookies, data=data, nocache=nocache, cache_time=cache_time)
         gobject.idle_add(lambda: self.__emit_results(url, data, cb, fname, fdata))
     except Exception, e:
         self.__logger.info("caught error for fetch of %s: %s" % (url, e))
         # in my experience sys.exc_info() is some kind of junk here, while "e" is useful
         gobject.idle_add(lambda: errcb(url, sys.exc_info()) and False)
Exemplo n.º 2
0
 def fetch(self, url, cb, errcb, cookies=None, data=None, nocache=False, cache_time=None):        
     try:
         # try the local cache first
         (fname, fdata) = httpcache.load(url, cookies, data=data, nonetwork=True, cache_time=cache_time)
         gobject.idle_add(lambda: self.__emit_results(url, data, cb, fname, fdata))
     except RuntimeError, e:
         self.__work_lock.acquire()
         self.__work_queue.append((url, cb, errcb, cookies, data, nocache, cache_time))
         self.__work_cond.notify()
         self.__work_lock.release()