8

In Python, is it possible to do a non-blocking system call without forking off a thread? i.e., can I avoid:

import thread
thread.start_new_thread(os.system,('cmd',))
Ross Rogers
  • 22,451
  • 24
  • 104
  • 161

1 Answers1

10

Use the subprocess module (Popen) and have the result written to a file. You can either "wait" for the subprocess to terminate or proceed with other business and poll for the result in the file etc.

jldupont
  • 88,026
  • 55
  • 193
  • 310