Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having Trouble With Threading
#1
This code isn't throwing errors, instead it's only giving me limited results based on "for i in range(20)" line. If I have it set as '20' it will only scrape 20 results, if I change it to '10' it will give me 10 etc.

It's ignoring the while loop requirements and I can't figure out why.

The script requires a test.csv file in working dir, here are some URLs: https://pastebin.com/TNYDBvTF

EXPAND CODE:
Reply
#2
Suggest you take a gander at: https://pymotw.com/3/threading/

You'll probably be interested in: greenteapress.com/semaphores/LittleBookOfSemaphores.pdf
also as it shows how to communicate between threads
Reply
#3
threads = []
for i in range(5):
    t = threading.Thread(target=worker, args=(i,))
    threads.append(t)
    t.start()
Does this code only generate the number of threads, or does it also automatically assign them to the project as well?

Am I having a problem with variables inside the main loop conflicting with the threads or is it a problem of not assigning threads properly or..? Where specifically am I not setting this up correctly?
Reply


Forum Jump:

User Panel Messages

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