Python Forum
Queuing the file content and run the thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Queuing the file content and run the thread.
#1
Hello,
I have a list of network devices in a file (each line is a device). I am passing each device or each line of that file as an argument to a curl statement to get the interfaces from the devices. The problem is, since there are more than 20K devices - it is actually taking a lot of time to get all the interfaces. 
This led me into threading and queuing module. Now, I am queuing all the devices and then running the thread. The thread contains the function to pull the interfaces. 
with open("filtered_devices") as my_file:
   for line in my_file:
     q.put(line)

numofThreads = 10.
for i in range (numofThreads):
   print str(threading.activeCount())
   t = threading.Thread(target = queue_interfaces())
   t.start()
   #threadlist.append(t)
Here, queue_interfaces() is the function that passes each devices as as argument and gets the interfaces. Not sure if this is the correct way to do that. May be I am doing it wrong, since the time is still the same. Can somebody please advise?
Also, my active thread count is not incrementing.
Reply


Messages In This Thread
Queuing the file content and run the thread. - by pythonlover - Jan-18-2017, 07:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Queuing Theory in Python NOLA_Saints 0 844 Feb-22-2023, 11:42 PM
Last Post: NOLA_Saints
  Extracting Specific Lines from text file based on content. jokerfmj 8 3,252 Mar-28-2022, 03:38 PM
Last Post: snippsat
Thumbs Up Parsing a YAML file without changing the string content..?, Flask - solved. SpongeB0B 2 2,380 Aug-05-2021, 08:02 AM
Last Post: SpongeB0B
  Opening file and outputting its text content example leodavinci1990 1 1,953 Oct-12-2020, 05:33 AM
Last Post: buran
  how to view file content of .docx while in Recycling bin NeoPy1 0 1,469 Sep-16-2020, 10:11 PM
Last Post: NeoPy1
  copy content of text file with three delimiter into excel sheet vinaykumar 0 2,440 Jul-12-2020, 01:27 PM
Last Post: vinaykumar
  Read content of GitHub file sridhar 5 10,289 Apr-29-2020, 11:49 PM
Last Post: sridhar
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,889 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE
  How do I read the HTML files in a directory and write the content into a CSV file? glittergirl 1 2,677 Sep-23-2019, 11:01 AM
Last Post: Larz60+
  save content of table into file atlass218 10 10,272 Aug-28-2019, 12:12 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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