def run(self):
        self.logger.info('thread started')
        # main loop
        event = XEvent()
        data = ''
        while not self.loop_break and x11:
            while x11.XPending(self.disp):
                self.loop_timeout = 0.0001
                x11.XNextEvent(self.disp, byref(event))
                # events we get here are already prefiltered by the predicate function
                if event.type == ClientMessage:
                    if event.xclient.format == 8:
                        if event.xclient.message_type == self.atom_msg_begin:
                            data = str(event.xclient.data)
                        elif event.xclient.message_type == self.atom_msg:
                            if data != '':
                                data += str(event.xclient.data)
                            else:
                                self.logger.warning('Middle of Skype X11 message received with no beginning!')
                        else:
                            continue
                        if len(event.xclient.data) != 20 and data:
                            self.notify(data.decode('utf-8'))
                            data = ''
                elif event.type == PropertyNotify:
                    namep = x11.XGetAtomName(self.disp, event.xproperty.atom)
                    is_inst = (c_char_p(namep).value == '_SKYPE_INSTANCE')
                    x11.XFree(namep)
                    if is_inst:
                        if event.xproperty.state == PropertyNewValue:
                            self.win_skype = self.get_skype()
                            # changing attachment status can cause an event handler to be fired, in
                            # turn it could try to call Attach() and doing this immediately seems to
                            # confuse Skype (command '#0 NAME xxx' returns '#0 CONNSTATUS OFFLINE' :D);
                            # to fix this, we give Skype some time to initialize itself
                            time.sleep(1.0)
                            self.set_attachment_status(apiAttachAvailable)
                        elif event.xproperty.state == PropertyDelete:
                            self.win_skype = None
                            self.set_attachment_status(apiAttachNotAvailable)
            self.loop_event.wait(self.loop_timeout)
            if self.loop_event.isSet():
                self.loop_timeout = 0.0001
            elif self.loop_timeout < 1.0:
                self.loop_timeout *= 2
            self.loop_event.clear()
        self.logger.info('thread finished')
dataset/ETHPy150Open Skype4Py/Skype4Py/Skype4Py/api/posix_x11.py/SkypeAPI.run/original