xml.etree.ElementTree.fromstring()
で関数が呼び出されると、無限のブロックがありQThread
ます。また、他の多くの呼び出しにより、QThreadがのようにブロックされmultiprocessing.Process()
ます。それは純粋なブロックであり、例外や中断はないと言うことが重要です。
コードは次のとおりです(少し編集されていますが、ソースと同じ原則です)。
from PyQt4.QtGui import *
from Ui_mainwindow import Ui_MainWindow
import sys
import xml.etree
class Bruton(QThread):
def __init__(self, mw):
super(Bruton, self).__init__(mw)
self.mw = mw
def run(self):
print("This message I see.")
tree = xml.etree.ElementTree.fromstring("<element>text</element>")
print("But this one never.")
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.init_bruton()
# When the form is shown...
def showEvent(self, arg1):
self.bruton.start()
def init_bruton(self):
self.bruton = Bruton(self)
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())