[LAD] Python assistance - threads (my favorite)

Patrick Shirkey pshirkey at boosthardware.com
Thu Oct 14 22:04:54 UTC 2010


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."




More information about the Linux-audio-dev mailing list