There is a problem that the code cannot continue to execute after the Python threading thread cannot jump out.

When

encounters the same problem, the while True in the method called by the
thread cannot jump out of the thread ending the while loop outside the while

.
def startsendfile(self,filelist,taskpath,filetypepath):

    for k in range(2):
        -sharp new_thread = threading.Thread(target=self.booth(k,filelist,taskpath,filetypepath))
        new_thread = threading.Thread(target=self.booth,args=(k,filelist,taskpath,filetypepath))
        -sharp new_thread.setDaemon(True)
        self.thread_list.append(new_thread)
    for t in self.thread_list:
        t.start()
    for t in self.thread_list:
        t.join()
    print("", time_now())

Thread calls methods


def booth(self,tid, filelist,taskpath,filetypepath):
    global thread_data_num
    global lock
    while True:
        self.lock.acquire()
        print(self.thread_data_num)
        if self.thread_data_num != 0:
            self.thread_data_num = self.thread_data_num - 1
            item = filelist[self.thread_data_num]
            time.sleep(10)
        else:
            break
        self.lock.release()
    print("")
    

is the result printed = > is it out

but does not print = > all threads end

Dec.20,2021

break before the lock is released, deadlock


the thread_data_num in the code you give has always been 0, so the loop in the booth will immediately break, print: have you come out? because all the threads in the startsendfile are blocked in the t.join () position, the thread has been waiting and will not print: all threads have ended

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3117c-2bd62.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3117c-2bd62.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?