I have been working with Python for a while, but so far I have never done any concurrency. I came across this blog post and decided to make a similar (but simpler) example:
import os import threading import Queue class Worker(threading.Thread): def __init__(self, queue, num): threading.Thread.__init__(self) self.queue = queue self.num = num def run(self): while True: text = self.queue.get()
Everything seems to be working fine, but there seem to be some fingerprint issues that I cannot understand. Several test runs:
chris@DPC3 :~/code/pythonthreading$ python owntest.py 0 :: BLUBTOR 1 :: more nonsense 3 :: cookies taste good 2 :: what is?! chris@DPC3 :~/code/pythonthreading$ python owntest.py 0 :: BLUBTOR 2 :: more nonsense 3 :: cookies taste good0 :: what is?! chris@DPC3 :~/code/pythonthreading$ python owntest.py 2 :: BLUBTOR 3 :: more nonsense1 :: cookies taste good 2 :: what is?! chris@DPC3 :~/code/pythonthreading$
Why is the output file formatted this weird?
source share