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
#1
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.

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:
    pass
I'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
Reply


Messages In This Thread
function/nonetype object is not iterable - by nanok66 - May-06-2020, 09:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 816 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 1,125 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,515 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not subscriptable syafiq14 3 5,338 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,752 Mar-28-2022, 04:42 PM
Last Post: Larz60+
  AttributeError: 'NoneType' object has no attribute 'group' MaartenRo 3 4,845 Jan-02-2022, 09:53 AM
Last Post: snippsat
  AttributeError: 'NoneType' object has no attribute 'group' MaartenRo 3 2,776 Jan-01-2022, 04:16 PM
Last Post: MaartenRo
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,351 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