Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

Ville Vainio vivainio at gmail.com
Mon Jul 20 12:12:25 CEST 2009


Has anyone implementing something like what the subject line
indicates?

The idea:

To run functions that execute a series of system commands without
blocking the ui, *and* without adding state machine logic.

The syntax would be something like:

def work():

  showstatus("building")
  r = yield runshell("make")
  showstatus("installing")
  r = yield runshell("make install")
  showstatus("Success")

mygui.startwork(work)
# returns immediately, runs work() gradually in the background.


The catch is that showstatus() would need to be run in the mainloop,
so running the whole thing in a thread is a no-go.

I imagine runshell() would be implemented in terms of QProcess, or
subprocess.Popen/os.system and a worker thread.

Anyone done this already, or do I have to roll my own?



More information about the Python-list mailing list