Re: [LAD] Python assistance - threads (my favorite)

From: Dominic Sacré <dominic.sacre@email-addr-hidden>
Date: Fri Oct 15 2010 - 10:02:09 EEST

On Fri, Oct 15, 2010 at 12:04 AM, Patrick Shirkey
<pshirkey@email-addr-hidden> 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.
>
> ...
> t = threading.Timer(5.0, self.do_popen(cmd))

This line seems to be your problem. You need to give threading.Timer
the function to be called, but instead your *calling* do_popen
immediately. After five seconds the timer then tries to call the
return value of do_popen, which is None.

One possible solution would be:
t = threading.Timer(5.0, functools.partial(self.do_popen, cmd))

Dominic
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Fri Oct 15 12:15:02 2010

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