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.
#9
Thanks a lot [b]micseydel ! [/b]BTW, I have already fixed my code. Sorry, that I didn't update the thread. [Part of my code:]

# Queuing
q = Queue.Queue(maxsize=0)
lock = threading.Lock()   # Lock the file while writing for 1 thread

#Threading
with open("filtered_devices") as my_file:
    for line in my_file:
      q.put(line)

numofThreads = 20

for i in range (numofThreads):
    print "Threading Count No:%d" %i
    t = threading.Thread(target = queue_interfaces, args=(q,))
    t.setDaemon(True)
    t.start()

q.join()
Reply


Messages In This Thread
RE: Queuing the file content and run the thread. - by pythonlover - Jul-27-2017, 10:00 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,253 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