fork download
  1. import subprocess
  2. import threading
  3. import time
  4.  
  5. def loop():
  6. subprocess.call('nslookup google.com')
  7. time.sleep(60 * 30)
  8.  
  9. t = threading.Thread(target=loop)
  10. t.daemon = True
  11. t.start()
  12. while t.is_alive():
  13. time.sleep(1)
  14.  
Success #stdin #stdout #stderr 0.18s 19304KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.2/threading.py", line 693, in run
    self._target(*self._args, **self._kwargs)
  File "./prog.py", line 6, in loop
  File "/usr/lib/python3.2/subprocess.py", line 471, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python3.2/subprocess.py", line 745, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.2/subprocess.py", line 1371, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 2] No such file or directory: 'nslookup google.com'