- def check_url(self, bookmark):
- if not check_subp:
- restart_subp(self.log) # Not restart, just start afresh
-
- try:
- save_parent = bookmark.parent
- bookmark.parent = None
-
- bookmark.tempfname = self.tempfname
- subp_pipe.write_record(pickle.dumps(bookmark))
-
- if check_subp.waitForPendingChar(900): # wait 15 minutes
- new_b = pickle.loads(subp_pipe.read_record())
- for attr in ("error", "no_error",
- "moved", "size", "md5", "real_title",
- "last_tested", "last_modified", "test_time", "icon"):
- if hasattr(new_b, attr):
- setattr(bookmark, attr, getattr(new_b, attr))
- else:
- bookmark.error = "Subprocess connection timed out"
- restart_subp(self.log)
-
- bookmark.parent = save_parent
-
- while True:
- error = check_subp.readPendingErrLine()
- if not error:
- break
- sys.stderr.write(error)
-
- except KeyboardInterrupt:
- return 0
-
- # Tested
- return 1
-
-
- def stop(self):
- stop_subp(None) # Stop subprocess; do not log restarting
+ subproc = 'urllib2' # Default subprocess
+
+ def check_url(self, bookmark):
+ global _set_subproc
+ if _set_subproc:
+ _set_subproc = False
+
+ subproc = self.subproc
+ subproc_attrs = []
+ for attr in dir(self):
+ if attr.startswith('subproc_'):
+ subproc_attrs.append((attr[len('subproc_'):], getattr(self, attr)))
+ if subproc_attrs:
+ subproc += ':' + ':'.join(['='.join((k,v)) for k,v in subproc_attrs])
+ os.environ['BKMK_ROBOT'] = subproc
+
+ if not check_subp:
+ restart_subp(self.log) # Not restart, just start afresh
+
+ try:
+ save_parent = bookmark.parent
+ bookmark.parent = None
+ subp_pipe.write_record(pickle.dumps(bookmark))
+
+ if check_subp.waitForPendingChar(60): # wait a minute
+ new_b = pickle.loads(subp_pipe.read_record())
+ for attr in ("error", "no_error",
+ "moved", "size", "md5", "real_title",
+ "last_tested", "last_modified", "test_time",
+ "icon", "icon_href"):
+ if hasattr(new_b, attr):
+ setattr(bookmark, attr, getattr(new_b, attr))
+ else:
+ bookmark.error = "Subprocess connection timed out"
+ restart_subp(self.log)
+
+ bookmark.parent = save_parent
+
+ while True:
+ error = check_subp.readPendingErrLine()
+ if not error:
+ break
+ sys.stderr.write("(subp) " + error)
+ sys.stderr.flush()
+
+ except KeyboardInterrupt:
+ return 0
+
+ # Tested
+ return 1
+
+ def stop(self):
+ stop_subp(None) # Stop subprocess; do not log restarting