PyQt5 uses QThread to separate UI and logic, and as a result, UI still gets stuck.

class Ux(QMainWindow, window.Ui_MainWindow):
    @pyqtSlot()
    def do_stop_search(self):
        pass

    @pyqtSlot(dict)
    def do_append_result(self, item):
        pass
    
    def on_btn_search_clicked(self):
        self.search = SearchThread(self, text)
        self.search.run()


class SearchThread(QThread):
    to_append_result = pyqtSignal([dict])
    to_stop_search = pyqtSignal()

    def __init__(self, obj, key_word):
        super().__init__()
        self.site = obj.site         -sharp obj.site is a class
        self.key = key_word
        self.to_append_result.connect(obj.do_append_result)
        self.to_stop_search.connect(obj.do_stop_search)

    def run(self):
        search = self.site(self.to_append_result)
        search.search(self.key)     -sharp do a lot of things
        self.to_stop_search.emit()

what"s wrong with this implementation?

Mar.04,2021

has been resolved, self.search.run () is used incorrectly.

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-1b3669c-2c027.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-1b3669c-2c027.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?