当前位置: 首页>>代码示例>>Python>>正文


Python QMutex.lock方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QMutex.lock方法的典型用法代码示例。如果您正苦于以下问题:Python QMutex.lock方法的具体用法?Python QMutex.lock怎么用?Python QMutex.lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QMutex的用法示例。


在下文中一共展示了QMutex.lock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
 def run(self):
     mutex = QMutex()
     mutex.lock()
     try:
         if self.method == 'post':
             response = self.session.post(self.url, data=self.data, files=self.files)
         elif self.method == 'get':
             response = self.session.get(self.url)
         elif self.method == 'delete':
             response = self.session.delete(self.url)
         else:
             raise Exception('不正确的方法')
         if response.status_code >= 300:
             try:
                 data = response.json()
                 if 'non_field_errors' in data:
                     error_message = data['non_field_errors']
                 else:
                     error_message = data.get('error', '未知错误')
                 message = '网络请求错误,错误码为{},原因为{}'.format(response.status_code, error_message)
                 self.failed.emit(message)
             except:
                 print(response.text)
         else:
             data = response.json()
             self.success.emit(data)
     except requests.Timeout as error:
         self.failed.emit('网络请求错误,超时,请检查网络连接')
     except BaseException as error:
         print('BaseException'.format(error))
         self.failed.emit(str(error.args))
     finally:
         mutex.unlock()
         self.deleteLater()
开发者ID:rui19921122,项目名称:MeetingsDesktop_v2,代码行数:36,代码来源:requests.py

示例2: QCallbacksManager

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class QCallbacksManager(QObject):
    class Request(object):
        def __init__(self):
            self.event = Event()
            self.answer = None

        def __call__(self):
            raise NotImplementedError()

    class LoginRequest(Request):
        def __init__(self, backend_name, value):
            super(QCallbacksManager.LoginRequest, self).__init__()
            self.backend_name = backend_name
            self.value = value

        def __call__(self):
            password, ok = QInputDialog.getText(None,
                '%s request' % self.value.label,
                'Please enter %s for %s' % (self.value.label,
                                            self.backend_name),
                                                QLineEdit.Password)
            return password

    new_request = Signal()

    def __init__(self, weboob, parent=None):
        super(QCallbacksManager, self).__init__(parent)
        self.weboob = weboob
        self.weboob.requests.register('login', self.callback(self.LoginRequest))
        self.mutex = QMutex()
        self.requests = []
        self.new_request.connect(self.do_request)

    def callback(self, klass):
        def cb(*args, **kwargs):
            return self.add_request(klass(*args, **kwargs))
        return cb

    @Slot()
    def do_request(self):
        self.mutex.lock()
        request = self.requests.pop()
        request.answer = request()
        request.event.set()
        self.mutex.unlock()

    def add_request(self, request):
        self.mutex.lock()
        self.requests.append(request)
        self.mutex.unlock()
        self.new_request.emit()
        request.event.wait()
        return request.answer
开发者ID:P4ncake,项目名称:weboob,代码行数:55,代码来源:qt.py

示例3: Lock

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class Lock(object):

    def __init__(self):
        self._mutex = QMutex()

    def __enter__(self):
        self._mutex.lock()

    def __exit__(self, type, value, tb):
        self._mutex.unlock()

    def acquire(self):
        self._mutex.lock()

    def release(self):
        self._mutex.unlock()
开发者ID:caetanus,项目名称:pygel,代码行数:18,代码来源:qt5_reactor.py

示例4: Evaluate

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class Evaluate(QThread):
    """Thread used to insolate calculation process in entities (stream, project
    and equipment, so gui can response while calculation is in process"""
    def __init__(self, parent=None):
        super(Evaluate, self).__init__(parent)
        self.mutex = QMutex()

    def start(self, entity, kwargs):
        self.entity = entity
        self.kwargs = kwargs
        QThread.start(self)

    def run(self):
        self.mutex.lock()
        self.entity(**self.kwargs)
        self.mutex.unlock()
开发者ID:ChEsolve,项目名称:pychemqt,代码行数:18,代码来源:thread.py

示例5: FetchPage

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class FetchPage(QThread):
    fetchSignal = pyqtSignal(str, name='fetchComplete')

    def __init__(self, parent=None):
        super(FetchPage, self).__init__(parent)
        print('thread initialized')
        self.mutex = QMutex()
        self.condition = QWaitCondition()

        self.restart = False
        self.abort = False

    def __del__(self):
        self.mutex.lock()
        self.abort = True
        self.condition.wakeOne()
        self.mutex.unlock()

        self.wait()

    def fetch(self, page):
        locker = QMutexLocker(self.mutex)
        self.page = page
        if page.content is not None:
            print('Returning old content')
            self.fetchSignal.emit(page.content)
        else:
            if not self.isRunning():
                self.start(QThread.LowPriority)
            else:
                self.restart = True
                self.condition.wakeOne()

    def run(self):
        print("running page fetch for " + self.page.title)
        rest_api = RestAPI()
        self.page.content = (rest_api.get_page_content(self.page.content_url))
        # print(self.page.content)
        self.fetchSignal.emit(self.page.content)
        # self.fetchSignal.emit()
        print('signal emitted')
        self.mutex.lock()
        if not self.restart:
            self.condition.wait(self.mutex)
        self.restart = False
        self.mutex.unlock()
开发者ID:lighht,项目名称:pyonenote-old,代码行数:48,代码来源:pages.py

示例6: Console

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class Console(QObject):
    """
    The stream-like-object to redirect stream to Qt editor document
    """
    update = pyqtSignal(str)  # something is writen to console

    def __init__(self, editor, color=None, parent=None, waitCond=None):
        """
        :param editor: QTextBrowser or QPlainTextEditor etc.
        :param color: text color
        :return:
        """
        super(Console, self).__init__(parent)

        self.editor = editor
        self.color = color
        if self.color:
            self.editor.setTextColor(self.color)

        self.mutex = QMutex()
        self.waitCond = waitCond
        self.input = None

    def write(self, content):
        """
        Append to editor's document
        :param content:
        :return:
        """
        self.update.emit(content)

    def read(self):
        self.editor.setReadOnly(False)

        self.mutex.lock()
        self.waitCond.wait(self.mutex)
        self.mutex.unlock()
        return self.input

    def close(self):
        pass

    @pyqtSlot(str)
    def receivedInput(self, content):
        self.input = content
开发者ID:YieldNull,项目名称:cinter,代码行数:47,代码来源:window.py

示例7: SyncAllThread

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class SyncAllThread(QThread):
    syncCompleteSignal = pyqtSignal(Dbm, name="syncComplete")

    def __init__(self, parent=None):
        super(SyncAllThread, self).__init__(parent)
        print("thread initialized")
        self.mutex = QMutex()
        self.condition = QWaitCondition()

        self.restart = False
        self.abort = False

    def __del__(self):
        self.mutex.lock()
        self.abort = True
        self.condition.wakeOne()
        self.mutex.unlock()

        self.wait()

    def sync(self):
        locker = QMutexLocker(self.mutex)
        self.dbm = Dbm()
        print("in sync thread")
        if not self.isRunning():
            self.start(QThread.LowPriority)
        else:
            self.restart = True
            self.condition.wakeOne()

    def run(self):
        print("running sync thread")
        self.dbm.fetch()
        # print(self.page.content)
        self.syncCompleteSignal.emit(self.dbm)
        # self.fetchSignal.emit()
        print("signal emitted")
        self.mutex.lock()
        if not self.restart:
            self.condition.wait(self.mutex)
        self.restart = False
        self.mutex.unlock()
开发者ID:lighht,项目名称:pyonenote-old,代码行数:44,代码来源:database_manager.py

示例8: FunctionThread

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class FunctionThread(QThread):
    executed = pyqtSignal(dict)

    def __init__(self, parent=None):
        super(FunctionThread, self).__init__(parent)

        self.mutex = QMutex()
        
        self.function = None
        self.args = None
        self.kwargs = None
        self.returnValue = None

        self.finished.connect(self.on_thread_finished)

        self.done = True

    def __del__(self):
        self.wait()

    def execute(self, function, *args, **kwargs):
        locker = QMutexLocker(self.mutex)

        self.function = function
        self.args = args
        self.kwargs = kwargs
        self.done = False

        self.start()

    def run(self):
        returnValue = self.function(*self.args, **self.kwargs)
        self.mutex.lock()
        self.returnValue = returnValue
        self.mutex.unlock()

    def on_thread_finished(self):
        result = {'returnValue': self.returnValue}
        self.done = True
        self.executed.emit(result)
开发者ID:johnymachine,项目名称:csv2db,代码行数:42,代码来源:database.py

示例9: SyncEventHandler

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class SyncEventHandler(QThread):
    notify_signal = pyqtSignal(object)
    enqueue_signal = pyqtSignal(object)
    done_signal = pyqtSignal()

    def __init__(self):
        super().__init__()

        self.queue = Queue()
        self.mutex = QMutex()

        self.enqueue_signal.connect(self.queue.put)
        self.done_signal.connect(self.mutex.unlock)

        self.start()

    def done(self):
        self.done_signal.emit()

    def run(self):
        while True:
            self.mutex.lock()
            event = self.queue.get()
            self.notify_signal.emit(event)
开发者ID:CenterForOpenScience,项目名称:osf-sync,代码行数:26,代码来源:tray.py

示例10: SwitchRefreshThread

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class SwitchRefreshThread(QThread):
    
    # Initialize class signals.
    data_signal = pyqtSignal(bool)
    
    """
    This function is responsible for initializing any related objects for 
    refresh thread.
    """
    def __init__(self, plugin_id, address, socket):
        QThread.__init__(self)
        self.plugin_id = plugin_id
        self.address = address
        self.udp_socket = socket
        self.finished.connect(self.quit)
        self.wait = QWaitCondition()
        self.mutex = QMutex()

    """
    This is the entry point for refresh thread.
    """
    def run(self):
        
        # Run indefinately.
        while True:
            
            # Wait for trigger.
            self.mutex.lock()
            self.wait.wait(self.mutex)
            self.mutex.unlock()
            
            # Receive and discard any datagrams from this socket.
            self.udp_socket.setblocking(0)
            try:
                while True:
                    _ = self.udp_socket.recv(65535)
            except:
                pass
            self.udp_socket.setblocking(1)
            self.udp_socket.settimeout(WV_REQ_TIMEOUT)
            
            try:
                rx_data = None
                
                if DEBUG:
                    print("Sending an update request for", self.plugin_id, "to", self.address)
                
                # Send a request update for this plugin.
                self.udp_socket.sendto(bytes.fromhex(WV_UPDATE) + bytes([((self.plugin_id & 0xFF00) >> 8), (self.plugin_id & 0x00FF)]), self.address)
                
                # Receive data form the UDP port.
                rx_data = self.udp_socket.recv(65535)
            
                # If we did receive a vaild reply.
                if (rx_data[ : 4] == bytes.fromhex(WV_UPDATE_REPLY)):
                    
                    # Remove packet descriptor.
                    rx_data = rx_data[4 : ]
                    
                    # If we did receive some data.
                    if len(rx_data) == 1:
                        if DEBUG:
                            print("Got an update for", self.plugin_id, "from", self.address)
                        
                        # Check if we are now turned on.
                        if (rx_data[0] == WV_PLUGIN_SWITCH_ON):
                            
                            # Signal the data to update the plugin display.
                            self.data_signal.emit(True)
                        
                        # Check if we are now turned off.
                        elif (rx_data[0] == WV_PLUGIN_SWITCH_OFF):
                            
                            # Signal the data to append the plugin display.
                            self.data_signal.emit(False)
                        else:
                            if DEBUG:
                                print("Invalid header for", self.plugin_id, "from", self.address)
                    else:
                        if DEBUG:
                            print("No data received for", self.plugin_id, "from", self.address, "or invalid data was received")
                else:
                    if DEBUG:
                        print("Invalid header for", self.plugin_id, "from", self.address)
    
            except:
                
                # Nothing to do here.
                pass
开发者ID:n3rd-bugs,项目名称:weird-rtos,代码行数:91,代码来源:plugin_switch.py

示例11: Ui

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class Ui(QMainWindow):
    shutdown_threads = pyqtSignal(name='shutdown_threads')

    def __init__(self):
        super(Ui, self).__init__()

        # Dictionary of methods to call in response to changes to
        # controls made directly on the amplifier.
        self.response_funcs = {
            'voice': self.voice_changed_on_amp,
            'gain': self.gain_changed_on_amp,
            'volume': self.volume_changed_on_amp,
            'bass': self.bass_changed_on_amp,
            'middle': self.middle_changed_on_amp,
            'treble': self.treble_changed_on_amp,
            'isf': self.isf_changed_on_amp,
            'tvp_switch': self.tvp_switch_changed_on_amp,
            'tvp_valve': self.tvp_valve_changed_on_amp,
            'mod_switch': self.mod_switch_changed_on_amp,
            'delay_switch': self.delay_switch_changed_on_amp,
            'reverb_switch': self.reverb_switch_changed_on_amp,
            'mod_type': self.mod_type_changed_on_amp,
            'mod_segval': self.mod_segval_changed_on_amp,
            'mod_level': self.mod_level_changed_on_amp,
            'mod_speed': self.mod_speed_changed_on_amp,
            'mod_manual': self.mod_manual_changed_on_amp,
            'delay_type': self.delay_type_changed_on_amp,
            'delay_feedback': self.delay_feedback_changed_on_amp,
            'delay_level': self.delay_level_changed_on_amp,
            'delay_time': self.delay_time_changed_on_amp,
            'reverb_type': self.reverb_type_changed_on_amp,
            'reverb_size': self.reverb_size_changed_on_amp,
            'reverb_level': self.reverb_level_changed_on_amp,
            'fx_focus': self.fx_focus_changed_on_amp,
            'preset': self.preset_changed_on_amp,
            'manual_mode': self.manual_mode_changed_on_amp,
            'tuner_mode': self.tuner_mode_changed_on_amp,
            'tuner_note': self.tuner_note_changed_on_amp,
            'tuner_delta': self.tuner_delta_changed_on_amp,
            'resonance': self.resonance_changed_on_amp,
            'presence': self.presence_changed_on_amp,
            'master_volume': self.master_volume_changed_on_amp,
            'preset_name': self.preset_name_from_amp,
            'preset_settings': self.preset_settings_from_amp,
        }

        uif = os.path.join(os.path.split(__file__)[0], 'outsider.ui')
        logger.debug('loading GUI file: {0}'.format(uif))
        uic.loadUi(uif, self)

        self.amp_mutex = None
        self.amp = BlackstarIDAmp()
        self.watcher_thread = None

        # For now we don't do anything with preset settings
        # information other than store them in this list
        self.preset_settings = [None] * 128

        self.controls_enabled(False)
        self.show()

    def controls_enabled(self, bool):
        # Disable/Enable all widgets except the connect button (always enabled) and the master controls (always disabled)
        if bool is True:
            widgets = self.findChildren(QGroupBox)#(QObject)
            for w in widgets:
                if w == self.masterGroupBox:
                   pass
                elif w.objectName() == 'TVPGroupBox' and self.amp.model == 'id-core':
                    # self.TVPComboBox.setCurrentText('6L6')
                    # self.TVPRadioButton.setChecked(False)
                    # Don't enable as Core has  fixed TVP, probably with type 6L6
                    pass
                else:
                    w.setEnabled(bool)

        elif bool is False:
            widgets = self.findChildren(QGroupBox)#(QObject)
            for w in widgets:
                w.setEnabled(bool)

            widgets = self.findChildren(QSlider)
            for w in widgets:
                w.blockSignals(True)
                w.setValue(0)
                w.blockSignals(False)

            widgets = self.findChildren(QLCDNumber)
            for w in widgets:
                w.blockSignals(True) # Not nescessary
                w.display(0)
                w.blockSignals(False) # Not nescessary

            widgets = self.findChildren(QRadioButton)
            for w in widgets:
                w.blockSignals(True)
                w.setChecked(False)
                w.blockSignals(False)

    def connect(self):
#.........这里部分代码省略.........
开发者ID:jonathanunderwood,项目名称:outsider,代码行数:103,代码来源:outsider.py

示例12: RenderThread

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class RenderThread(QThread):
    ColormapSize = 512

    renderedImage = pyqtSignal(QImage, float)

    def __init__(self, parent=None):
        super(RenderThread, self).__init__(parent)

        self.mutex = QMutex()
        self.condition = QWaitCondition()
        self.centerX = 0.0
        self.centerY = 0.0
        self.scaleFactor = 0.0
        self.resultSize = QSize()
        self.colormap = []

        self.restart = False
        self.abort = False

        for i in range(RenderThread.ColormapSize):
            self.colormap.append(self.rgbFromWaveLength(380.0 + (i * 400.0 / RenderThread.ColormapSize)))

    def __del__(self):
        self.mutex.lock()
        self.abort = True
        self.condition.wakeOne()
        self.mutex.unlock()

        self.wait()

    def render(self, centerX, centerY, scaleFactor, resultSize):
        locker = QMutexLocker(self.mutex)

        self.centerX = centerX
        self.centerY = centerY
        self.scaleFactor = scaleFactor
        self.resultSize = resultSize

        if not self.isRunning():
            self.start(QThread.LowPriority)
        else:
            self.restart = True
            self.condition.wakeOne()

    def run(self):
        while True:
            self.mutex.lock()
            resultSize = self.resultSize
            scaleFactor = self.scaleFactor
            centerX = self.centerX
            centerY = self.centerY
            self.mutex.unlock()

            halfWidth = resultSize.width() // 2
            halfHeight = resultSize.height() // 2
            image = QImage(resultSize, QImage.Format_RGB32)

            NumPasses = 8
            curpass = 0

            while curpass < NumPasses:
                MaxIterations = (1 << (2 * curpass + 6)) + 32
                Limit = 4
                allBlack = True

                for y in range(-halfHeight, halfHeight):
                    if self.restart:
                        break
                    if self.abort:
                        return

                    ay = 1j * (centerY + (y * scaleFactor))

                    for x in range(-halfWidth, halfWidth):
                        c0 = centerX + (x * scaleFactor) + ay
                        c = c0
                        numIterations = 0

                        while numIterations < MaxIterations:
                            numIterations += 1
                            c = c*c + c0
                            if abs(c) >= Limit:
                                break
                            numIterations += 1
                            c = c*c + c0
                            if abs(c) >= Limit:
                                break
                            numIterations += 1
                            c = c*c + c0
                            if abs(c) >= Limit:
                                break
                            numIterations += 1
                            c = c*c + c0
                            if abs(c) >= Limit:
                                break

                        if numIterations < MaxIterations:
                            image.setPixel(x + halfWidth, y + halfHeight,
                                           self.colormap[numIterations % RenderThread.ColormapSize])
                            allBlack = False
#.........这里部分代码省略.........
开发者ID:death-finger,项目名称:Scripts,代码行数:103,代码来源:mandelbrot.py

示例13: Person

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]

#.........这里部分代码省略.........
        """
        Get the person self certification.
        This request is not cached in the person object.

        :param community: The community target to request the self certification
        :return: A SelfCertification ucoinpy object
        """
        data = community.request(bma.wot.Lookup, req_args={"search": self.pubkey})
        logging.debug(data)
        timestamp = 0

        for result in data["results"]:
            if result["pubkey"] == self.pubkey:
                uids = result["uids"]
                for uid_data in uids:
                    if uid_data["meta"]["timestamp"] > timestamp:
                        timestamp = uid_data["meta"]["timestamp"]
                        uid = uid_data["uid"]
                        signature = uid_data["self"]

                return SelfCertification(PROTOCOL_VERSION, community.currency, self.pubkey, timestamp, uid, signature)
        raise PersonNotFoundError(self.pubkey, community.name)

    @cached
    def get_join_date(self, community):
        """
        Get the person join date.
        This request is not cached in the person object.

        :param community: The community target to request the join date
        :return: A datetime object
        """
        try:
            search = community.request(bma.blockchain.Membership, {"search": self.pubkey})
            membership_data = None
            if len(search["memberships"]) > 0:
                membership_data = search["memberships"][0]
                return community.get_block(membership_data["blockNumber"]).mediantime
            else:
                return None
        except ValueError as e:
            if "400" in str(e):
                raise MembershipNotFoundError(self.pubkey, community.name)
        except Exception as e:
            logging.debug("bma.blockchain.Membership request error : " + str(e))
            raise MembershipNotFoundError(self.pubkey, community.name)

    # TODO: Manage 'OUT' memberships ? Maybe ?
    @cached
    def membership(self, community):
        """
        Get the person last membership document.

        :param community: The community target to request the join date
        :return: The membership data in BMA json format
        """
        try:
            search = community.request(bma.blockchain.Membership, {"search": self.pubkey})
            block_number = -1
            for ms in search["memberships"]:
                if ms["blockNumber"] > block_number:
                    block_number = ms["blockNumber"]
                    if "type" in ms:
                        if ms["type"] is "IN":
                            membership_data = ms
                    else:
开发者ID:sethkontny,项目名称:cutecoin,代码行数:70,代码来源:person.py

示例14: VcsStatusMonitorThread

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class VcsStatusMonitorThread(QThread):
    """
    Class implementing the VCS status monitor thread base class.
    
    @signal vcsStatusMonitorData(list of str) emitted to update the VCS status
    @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of
        the monitoring thread (ok, nok, op) and a status message
    """
    vcsStatusMonitorData = pyqtSignal(list)
    vcsStatusMonitorStatus = pyqtSignal(str, str)
    
    def __init__(self, interval, project, vcs, parent=None):
        """
        Constructor
        
        @param interval new interval in seconds (integer)
        @param project reference to the project object (Project)
        @param vcs reference to the version control object
        @param parent reference to the parent object (QObject)
        """
        super(VcsStatusMonitorThread, self).__init__(parent)
        self.setObjectName("VcsStatusMonitorThread")
        
        self.setTerminationEnabled(True)
        
        self.projectDir = project.getProjectPath()
        self.project = project
        self.vcs = vcs
        
        self.interval = interval
        self.autoUpdate = False
        
        self.statusList = []
        self.reportedStates = {}
        self.shouldUpdate = False
        
        self.monitorMutex = QMutex()
        self.monitorCondition = QWaitCondition()
        self.__stopIt = False
    
    def run(self):
        """
        Public method implementing the tasks action.
        """
        while not self.__stopIt:
            # perform the checking task
            self.statusList = []
            self.vcsStatusMonitorStatus.emit(
                "wait", self.tr("Waiting for lock"))
            try:
                locked = self.vcs.vcsExecutionMutex.tryLock(5000)
            except TypeError:
                locked = self.vcs.vcsExecutionMutex.tryLock()
            if locked:
                try:
                    self.vcsStatusMonitorStatus.emit(
                        "op", self.tr("Checking repository status"))
                    res, statusMsg = self._performMonitor()
                finally:
                    self.vcs.vcsExecutionMutex.unlock()
                if res:
                    status = "ok"
                else:
                    status = "nok"
                self.vcsStatusMonitorStatus.emit(
                    "send", self.tr("Sending data"))
                self.vcsStatusMonitorData.emit(self.statusList)
                self.vcsStatusMonitorStatus.emit(status, statusMsg)
            else:
                self.vcsStatusMonitorStatus.emit(
                    "timeout", self.tr("Timed out waiting for lock"))
            
            if self.autoUpdate and self.shouldUpdate:
                self.vcs.vcsUpdate(self.projectDir, True)
                continue    # check again
                self.shouldUpdate = False
            
            # wait until interval has expired checking for a stop condition
            self.monitorMutex.lock()
            if not self.__stopIt:
                self.monitorCondition.wait(
                    self.monitorMutex, self.interval * 1000)
            self.monitorMutex.unlock()
        
        self._shutdown()
        self.exit()
    
    def setInterval(self, interval):
        """
        Public method to change the monitor interval.
        
        @param interval new interval in seconds (integer)
        """
        locked = self.monitorMutex.tryLock()
        self.interval = interval
        self.monitorCondition.wakeAll()
        if locked:
            self.monitorMutex.unlock()
    
    def getInterval(self):
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:StatusMonitorThread.py

示例15: HelpDocsInstaller

# 需要导入模块: from PyQt5.QtCore import QMutex [as 别名]
# 或者: from PyQt5.QtCore.QMutex import lock [as 别名]
class HelpDocsInstaller(QThread):
    """
    Class implementing the worker thread populating and updating the QtHelp
    documentation database.
    
    @signal errorMessage(str) emitted, if an error occurred during
        the installation of the documentation
    @signal docsInstalled(bool) emitted after the installation has finished
    """

    errorMessage = pyqtSignal(str)
    docsInstalled = pyqtSignal(bool)

    def __init__(self, collection):
        """
        Constructor
        
        @param collection full pathname of the collection file (string)
        """
        super(HelpDocsInstaller, self).__init__()

        self.__abort = False
        self.__collection = collection
        self.__mutex = QMutex()

    def stop(self):
        """
        Public slot to stop the installation procedure.
        """
        if not self.isRunning():
            return

        self.__mutex.lock()
        self.__abort = True
        self.__mutex.unlock()
        self.wait()

    def installDocs(self):
        """
        Public method to start the installation procedure.
        """
        self.start(QThread.LowPriority)

    def run(self):
        """
        Public method executed by the thread.
        """
        engine = QHelpEngineCore(self.__collection)
        engine.setupData()
        changes = False

        qt4Docs = ["designer", "linguist", "qt"]
        qt5Docs = [
            "activeqt",
            "qtandroidextras",
            "qtbluetooth",
            "qtconcurrent",
            "qtcore",
            "qtdbus",
            "qtdesigner",
            "qtdoc",
            "qtenginio",
            "qtenginiooverview",
            "qtenginoqml",
            "qtgraphicaleffects",
            "qtgui",
            "qthelp",
            "qtimageformats",
            "qtlinguist",
            "qtlocation",
            "qtmaxextras",
            "qtmultimedia",
            "qtmultimediawidgets",
            "qtnetwork",
            "qtnfc",
            "qtopengl",
            "qtpositioning",
            "qtprintsupport",
            "qtqml",
            "qtquick",
            "qtquickcontrols",
            "qtquickdialogs",
            "qtquicklayouts",
            "qtscript",
            "qtscripttools",
            "qtsensors",
            "qtserialport",
            "qtsql",
            "qtsvg",
            "qttestlib",
            "qtuitools",
            "qtwebchannel",
            "qtwebengine",
            "qtwebenginewidgets",
            "qtwebkit",
            "qtwebkitexamples",
            "qtwebsockets",
            "qtwidgets",
            "qtwinextras",
            "qtx11extras",
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:HelpDocsInstaller.py


注:本文中的PyQt5.QtCore.QMutex.lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。