[LAD] Python assistance - threads (my favorite)

From: Patrick Shirkey <pshirkey@email-addr-hidden>
Date: Fri Oct 15 2010 - 01:04:54 EEST

Hi,

In a bit of a time crunch. Can anyone tell me how to do this properly?

I would like to have a threaded timer to run "cmd" after 5 seconds.
However cmd is normally triggered like this:

os.system(cmd)

But there seems to be an issue with calling os.system(cmd) from
subprocess.popen.

==========================

def do_popen(self, *args):
        subprocess.Popen(args[0], shell=True)

def other function

                cmd = 'spd-say -t female2 "' + audioText + '"'
                args = shlex.split(cmd)

        # Add 5 second delay for first view to allow existing speech processes to
finish
                print "do_speech: ",delay
                if delay:
                        print "do_speech: delayed start"
                        t = threading.Timer(5.0, self.do_popen(cmd))
                        t.start()
                else :
                        print "do_speech: immediate start"
                        self.do_popen(cmd)

======================

FYI, it is for an accessibility wizard that Daniel and I have been working
on.

Cheers.

-- 
Patrick Shirkey
Boost Hardware Ltd.
"ZPE is not about creating something from nothing: It is about using the
zero point of a wave as a means to transform other forms of potential
energy like magnetic flux, heat, or particle spin into usable energy in
such a way that entropy appears to be reversed."
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Fri Oct 15 04:15:02 2010

This archive was generated by hypermail 2.1.8 : Fri Oct 15 2010 - 04:15:02 EEST