multithreading - Python program gets deadlock -


my program gets deadlock after working half hour. use global thread safe queue usernamesqueue = queue(), main thread produces items queue , wait handling them:

while(true):     print('processing file...')        open('usernames') f:         line in f:             usernamesqueue.put(line.strip())      usernamesqueue.join() 

i start threads this:

for in range(number_of_workers):     threading.thread(target=worker).start() 

and handle values in queue this:

def worker():     while true:         time.sleep(1)          item = none          item = usernamesqueue.get()          if item not none:             processuser(item)              usernamesqueue.task_done()             time.sleep(random.randint(1, 5)) 

processuser catch exception can thrown , sure there weren't exceptions before deadlock. what's wrong?

there weren't problems deadlock, in httpsconnection default doesn't have timeout or have big, added timeout 15 seconds , program works fine when server doesn't want respond.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -