openpolitics.com

  • writing
  • quotes
  • Topics
    • academia
    • corruption
    • economics
    • education
    • environment
    • finance
    • history
    • hypertext
    • media
    • philosophy
    • psychology
    • religion
    • russia
    • ted nelson
  • about
← Previous Next →

The Basics of Python Multithreading and Queues

def do_stuff(q):
 while True:
 print q.get()
 q.task_done()

q = Queue(maxsize=0)
num_threads = 10
 
for i in range(num_threads):
 worker = Thread(target=do_stuff, args=(q,))
 worker.setDaemon(True)
 worker.start()
source: $link[host]

Tags: programming, python

Read Original Source

Tim Langeman © 2025 · Genesis Framework · WordPress · Log in