[PD] launching pd from python

august august at develop.ment.org
Fri Sep 2 18:52:31 CEST 2005


> I tried.os.system() and it does open Pd properly but python waits until
> PD is finished to keep running. I need both Python and PD to work
> concurrently. Same for os.execl()
>
> This is as far as i got. I use
>
> execdir = os.path.dirname(sys.argv[0])
> launcher = os.path.join(execdir, "launcher")
> os.spawnl(os.P_NOWAIT, launcher, '')

I just got some decent results usint python threading.

try this:

import threading, os
import time

class PdTask(threading.Thread):
   def __init__(self, command):
        threading.Thread.__init__(self)
        self.command = command
   def run(self):
        os.system(self.command)


exec_command = "/path/to/pd -arg 1 -arg 2"
pdthread = PdTask(exec_command)
pdthread.start()

while 1:
	# do all the python stuff you need
	# we'll just sleep here for testing purposes
	time.sleep(1)

# optionally you could wait for pd to quit before ending
pdthread.join()




More information about the Pd-list mailing list