I'm using the multiprocessing
module in Python 3 but for some reason, it keeps throwing TypeError: 'int' object is not iterable
when I run the program. This is what I did:
def main(i):
global urlDepth
global row
global counter
urlDepth = []
row = 0
counter = 0
login(i)
crawler(MENU_URL)
if __name__ == '__main__':
workers = 2
processes = []
for p_number in range(workers):
p = Process(target=main, args=p_number)
p.start()
processes.append(p)
for p in processes:
p.join()
I don't understand why this is happening, could someone help me with this?
Not a duplicate of TypeError: 'int' object is not iterable because it is the same error, yes, but it's of a different cause, please read the question/code before trying to mark this question as a duplicate.
p = Process(target=main, args=p_number)
args
needs to be a tuple, but you're giving it an integer. Try:
p = Process(target=main, args=(p_number,))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With