May-06-2020, 09:06 PM
Hi all,
I am getting error "functools.partial object not iterable". I google searched this issue and have read multiple answers about this issue but still cannot figure out how to rewrite my code to get my subprocess to run.
I am getting error "functools.partial object not iterable". I google searched this issue and have read multiple answers about this issue but still cannot figure out how to rewrite my code to get my subprocess to run.
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())
cycle = [emptyKeg(), emptyGlass()]
def runCycle(cycle):
for func in cycle:
try:
func
except ValueError:
break
sub = subprocess.Popen(partial(runCycle, cycle))
while True:
passI've also rewritten the program to be simpler, without using partial and I get error "nonetype object is not iterable". Again, I've read lot about this topic but still not sure what I am doing wrong.import time
import sched
import subprocess
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():
emptyKeg()
emptyGlass()
sub = subprocess.Popen(runCycle())
while True:
pass
