import unittest
import subprocess as sp
import time
import argparse

class MyTestCase(unittest.TestCase):


	def test_something(self):

		procs = []
		pipe = None
		for i in range(0, 6):

			#pipe = sp.Popen(f'php -v', shell=True)
			pipe = sp.Popen(f'php db_scrubber.php - -threadnumber={i}', shell=True)

			procs.append(pipe)

		for i in range(0,len(procs)):

			while procs[i].poll() is None:
				time.sleep(0.1)
				print(f'{procs[i]} sleeping...')

		self.assertEqual(True, True)


if __name__ == '__main__':
	unittest.main()



def parse_args(args=None):

	usage = "usage: %prog [options] arg"
	parser = argparse.ArgumentParser()

	parser.add_argument(
		"--threads", dest="THREADS", default=5,
		help="Number of threads to run. Default is 5")

	return parser.parse_args()


if __name__ == '__main__':

	ARGS = parse_args()

	print(f'Threads to run {ARGS.THREADS}')