Skip to content

Instantly share code, notes, and snippets.

@mikitebeka
Created August 17, 2010 18:11
Show Gist options
  • Select an option

  • Save mikitebeka/531214 to your computer and use it in GitHub Desktop.

Select an option

Save mikitebeka/531214 to your computer and use it in GitHub Desktop.
def stdout_readline(process):
return process.stdout.readline()
def make_web_readline(url):
def web_readline(process):
return urlopen(url).read()
return web_readline
def run_logger(server_process, name, readline):
def logfunc():
while True:
try:
line = readline(server_process)
except AttributeError:
break
exitcode = server_process.poll()
if (not line) and (exitcode is not None):
break
if line:
line = line[:-1]
log(name, line.rstrip())
daemon_thread(logfunc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment