Cool, changed my use of parenthesis like deanhystad suggested.
Commenting out my subprocess code, this script works now.
I suppose I should add that I was previously trying to use a thread to run my function runCycle. But now I'm trying to use subprocess instead of thread because subprocess has a method kill() that will quickly stop the code.
Hmm maybe Popen is not the best fit to run a function. I've got to do more reading on this. Thanks everyone for helping with my poor understanding of python!
Commenting out my subprocess code, this script works now.
import time import sched import subprocess from functools import partial s = sched.scheduler(time.time, time.sleep) def delay(set_time): s.enter(set_time, 1, pass_func) s.run() def pass_func(): pass def emptyKeg(): print("A start: ", time.time()) delay(5) print("A after 5: ", time.time()) def emptyGlass(): print("B start: ", time.time()) delay(5) print("B after 5: ", time.time()) def runCycle(cycle): for func in cycle: try: func() except ValueError: break cycleRun = [emptyKeg, emptyGlass] runCycle(cycleRun) # new line to replace the broken code below #sub = subprocess.Popen(partial(runCycle, cycleRun)) # broken, not sure whats wrong while True: passNow I just have to figure out how to make subprocess work.
I suppose I should add that I was previously trying to use a thread to run my function runCycle. But now I'm trying to use subprocess instead of thread because subprocess has a method kill() that will quickly stop the code.
Hmm maybe Popen is not the best fit to run a function. I've got to do more reading on this. Thanks everyone for helping with my poor understanding of python!