s = subprocess.Popen(['foo', 'args'])
timeout = 1
poll_period = 0.1
s.poll()
while s.returncode is None and timeout > 0:
    time.sleep(poll_period)
timeout -= poll_period
s.poll()
if timeout <= 0:
    s.kill()
else:
    pass
Run a external program with specified max running time