LINUX.ORG.RU

Сообщения ofilin86

 

Timers cannot be stopped from another thread

Форум — Development

Всем привет, подскажите, как решить?

class Worker(QtCore.QThread):
    login_event = QtCore.pyqtSignal(int)
    running = False

    def __init__(self, parent=None):
        super(Worker, self).__init__(parent)
        self.running = True
    def run(self):
        wmi = Moniker('winmgmts:')
        wmi_events = wmi.ExecNotificationQuery("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_NTLogEvent' AND TargetInstance.EventCode = 4625")
        while self.running:
            received_event = wmi_events.NextEvent()
            event = received_event.TargetInstance.InsertionStrings
            remote_username = event[5]
            print("Username: " + remote_username)
    def stop(self):
        self.running = False

class MainWindow(Ui_MainWindow):
    def __init__(self, dialog, db):
        super().__init__()
        Ui_MainWindow.__init__(self)
        self.setupUi(dialog)
        self.tmr = Worker(self)
        self.tmr.start()
Traceback (most recent call last):
  File "run_me.py", line 22, in run
    wmi = Moniker('winmgmts:')
  File "C:\Python35-32\lib\site-packages\win32com\client\__init__.py", line 87, in Moniker
    moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
pywintypes.com_error: (-2147221020, '?????????? ????', None, None)
QObject::~QObject: Timers cannot be stopped from another thread

 

ofilin86
()

RSS подписка на новые темы