4 Written by BroytMann. Copyright (C) 2000-2007 PhiloSoft Design
15 from subproc import Subprocess, RecordFile
22 global check_subp, subp_pipe
24 if log: log(" restarting hanging subprocess")
28 def restart_subp(log):
29 global check_subp, subp_pipe
32 check_subp = Subprocess("%s/Robots/bkmk_rforking_sub.py" % os.path.dirname(sys.argv[0]))
33 subp_pipe = RecordFile(check_subp)
36 from bkmk_objects import Robot
38 class robot_forking(Robot):
39 def check_url(self, bookmark, url_type, url_rest):
41 restart_subp(self.log) # Not restart, just start afresh
44 save_parent = bookmark.parent
45 bookmark.parent = None
47 bookmark.tempfname = self.tempfname
48 subp_pipe.write_record(pickle.dumps(bookmark))
50 if check_subp.waitForPendingChar(900): # wait 15 minutes
51 new_b = pickle.loads(subp_pipe.read_record())
52 for attr in ("error", "no_error",
53 "moved", "size", "md5", "real_title",
54 "last_tested", "last_modified", "test_time", "icon"):
55 if hasattr(new_b, attr):
56 setattr(bookmark, attr, getattr(new_b, attr))
58 bookmark.error = "Subprocess connection timed out"
59 restart_subp(self.log)
61 bookmark.parent = save_parent
63 except KeyboardInterrupt:
71 stop_subp(None) # Stop subprocess; do not log restarting