#!/usr/bin/env python
print "entering"


from threading import Thread
import threading
from commandsplus import getstatusoutputerror


def dum3():
# 	cmd = ["dcop","amarok","collection","query","select url from analysis where url = '/home/rudd-o/Musica/(Themes and soundtracks)/Buffy - the vampire slayer.mp3'"]
	cmd = "echo goma chucha pedo"
	print getstatusoutputerror(cmd)


def runinthreads(numthreads,target):
	import time
	bench = time.time()
	print "Doing %s"%target.__name__
	threads = []
	for a in range(numthreads):
		threads.append(Thread(target=target))
	for t in threads[:]:
		try: t.start()
		except: threads.remove(t)
	counter = 0
	for t in threads:
		t.join()
		counter = counter + 1
	print "%s done, %s threads waited, total time: %s" % (target.__name__,counter,time.time() - bench)


def dum2():
	runinthreads(5,dum3)

def dum():
	runinthreads(3,dum2)


while True:
	dum()

print "exiting"
