I have a large system with workers and manager threads.
I have run into the problem that one of the threads uses:
print "before time sleep"
time.sleep(5)
print "after time sleep"
It will print both a lot of times and then suddenly only display "before time sleep" And stop until i kill all the other threads. None of the other threads are stopping.
I think some other part of the code is locking the commandline output or something like that, but I have no idea how to find the spot (it can take up to 24 hours before it happens)
I'm using python 2.7 and the error occurs on a windows server.
I have the same issue, depending on what I put as a value in the "end" attribute of the print method, I got a threadLock:
from queue import LifoQueue
import threading
q = LifoQueue()
for i in range(100):
q.put(i)
def process_job(q, threadName):
while not q.empty():
print(q.get(), end=' ')
workers = [
threading.Thread(target=process_job, args=(q,'1')),
threading.Thread(target=process_job, args=(q,'2')),
threading.Thread(target=process_job, args=(q,'3')),
]
for w in workers:
w.setDaemon(True)
w.start()
The funniest part is that it works perfectly (as far as the end's value is blank " ").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With