Ross Rogers
Ross Rogers

Reputation: 24240

In python, how can I do a non-blocking system call?

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',))

Upvotes: 8

Views: 6831

Answers (1)

jldupont
jldupont

Reputation: 96806

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.

Upvotes: 10

Related Questions