On Thu, Oct 14, 2010 at 03:04:54PM -0700, Patrick Shirkey wrote:
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)
======================
A bit confusing - you mention os.system() but is not used at all
(nor should it if you use subprocess.Popen().
You didn't tell what happens...
I suspect that if you do this in a function the thread 't' will be
destroyed as soon as that function returns. Making 't' global could
help. (no guarantee -- speculating).
Ciao,
--
FA
There are three of them, and Alleline.