Python Forum
function/nonetype object is not iterable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function/nonetype object is not iterable
#6
Cool, changed my use of parenthesis like deanhystad suggested.

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:
    pass
Now 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!
Reply


Messages In This Thread
RE: function/nonetype object is not iterable - by nanok66 - May-08-2020, 07:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 819 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 1,126 Aug-24-2023, 05:14 PM
Last Post: snippsat
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,634 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,519 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not subscriptable syafiq14 3 5,339 Sep-19-2022, 02:43 PM
Last Post: Larz60+
Question how to solve `'TypeError: 'int' object is not iterable`? netanelst 2 1,642 May-24-2022, 12:03 PM
Last Post: deanhystad
  AttributeError: 'function' object has no attribute 'metadata 3lnyn0 5 4,753 Mar-28-2022, 04:42 PM
Last Post: Larz60+
  AttributeError: 'NoneType' object has no attribute 'group' MaartenRo 3 4,846 Jan-02-2022, 09:53 AM
Last Post: snippsat
  AttributeError: 'NoneType' object has no attribute 'group' MaartenRo 3 2,777 Jan-01-2022, 04:16 PM
Last Post: MaartenRo
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,361 Aug-17-2021, 05:24 PM
Last Post: Franky77

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020