Python Forum
how to start a seperate thread for every item in a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to start a seperate thread for every item in a list
#2
It is because you are creating a new list items in the process method and iterate over all of that items. Change the method to:
def process(item):
    print "Sleeping 2 sec from thread %s \n" % item
     
    time.sleep(1)
    #i=len(items)
    print "Finished sleeping from thread %s \n" % item
    try:
        base_path = '/ai2/data/dev/admin/inf/*{}*'
        search_path =  base_path.format(item)
        for f in glob.glob(search_path):
            print ("The directory path is:")
            print f
    except:
        print('error with pattern')
Reply


Messages In This Thread
RE: how to start a seperate thread for every item in a list - by ThiefOfTime - May-31-2018, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error: can't start new thread maha2 0 1,460 Jun-13-2023, 12:26 PM
Last Post: maha2
Question Finding string in list item jesse68 8 1,896 Jun-30-2022, 08:27 AM
Last Post: Gribouillis
  How to seperate dict value? ilknurg 2 1,358 Mar-11-2022, 10:48 AM
Last Post: perfringo
  how to easily create a list of already existing item CompleteNewb 15 3,580 Jan-06-2022, 12:48 AM
Last Post: CompleteNewb
  Remove an item from a list contained in another item in python CompleteNewb 19 5,788 Nov-11-2021, 06:43 AM
Last Post: Gribouillis
  count item in list korenron 8 3,497 Aug-18-2021, 06:40 AM
Last Post: naughtyCat
  Two separate dataframes, two seperate programs stylingpat 2 2,005 Apr-28-2021, 07:56 PM
Last Post: stylingpat
  Time.sleep: stop appending item to the list if time is early quest 0 1,884 Apr-13-2021, 11:44 AM
Last Post: quest
  Seperate output buffer matt_the_hall 2 2,371 Mar-15-2021, 08:44 PM
Last Post: matt_the_hall
  How to run a pytest test for each item in a list arielma 0 2,378 Jan-06-2021, 10:40 PM
Last Post: arielma

Forum Jump:

User Panel Messages

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