Daniel Dorman
Daniel Dorman

Reputation: 75

mutliprocess.Proccess(args) : TypeError: 'int' object is not iterable

So this error has beeen confusing me for the past 30 minutes and I am out of options.

if __name__ == "__main__":
    sub_array_index = 0
    for i in range(requested_threads):
        i = mp.Process(target=check_url, args=(sub_array_index))
        i.start
        threads.append(i)
        array_index += 1

    for i in threads:
        i.join()

when I run this snippet of code I get

TypeError: 'int' object is not iterable

as an error.

I am trying to use

 sub_array_index

as an index for accessing a sub array that has been split by

numpy.array_split(<array name>, <number of sub arrays)

is there anything I'm missing?

I have tried:

Thanks for the help!

Upvotes: 0

Views: 339

Answers (2)

Alex Mandelias
Alex Mandelias

Reputation: 517

The args parameter is a tuple, therefore it is interpreting sub_array_index as a tuple.

Do args=((sub_array_index,))

Upvotes: 1

JBernardo
JBernardo

Reputation: 33397

You should be missing a comma to make the args a tuple:

i = mp.Process(target=check_url, args=(sub_array_index,))

Otherwise the parenthesis won't do a thing and indeed it will be a single number

Upvotes: 1

Related Questions