IGN:Make job control a little more robust

This commit is contained in:
Kovid Goyal 2009-01-16 10:08:52 -08:00
parent 4e9dc3e87f
commit 532820ad8f
2 changed files with 9 additions and 2 deletions

View File

@ -77,6 +77,8 @@ def check_links(opf_path, pretty_print):
html_files.append(os.path.abspath(content(f)))
for path in html_files:
if not os.access(path, os.R_OK):
continue
base = os.path.dirname(path)
root = html.fromstring(open(content(path), 'rb').read(), parser=parser)
for element, attribute, link, pos in list(root.iterlinks()):

View File

@ -286,7 +286,7 @@ def write(socket, msg, timeout=5):
def read(socket, timeout=5):
'''
Read a message from `socket`. The message must have been sent with the :function:`write`
function. Raises a `RuntimeError` if the message is corrpted. Can return an
function. Raises a `RuntimeError` if the message is corrupted. Can return an
empty string.
'''
if isworker:
@ -299,7 +299,12 @@ def read(socket, timeout=5):
if not msg:
break
if length is None:
length, msg = int(msg[:12]), msg[12:]
try:
length, msg = int(msg[:12]), msg[12:]
except ValueError:
if DEBUG:
print >>sys.__stdout__, 'read(%s):'%('worker' if isworker else 'overseer'), 'no length in', msg
return ''
buf.write(msg)
if buf.tell() >= length:
break