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


Python QThreadPool.setMaxThreadCount方法代码示例

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


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

示例1: Tasks

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import setMaxThreadCount [as 别名]
class Tasks(QObject):
    def __init__(self, ar, process_result):
        super(Tasks, self).__init__()
        self.ar = ar
        self.process_result = process_result
        self.pool = QThreadPool()
        self.pool.setMaxThreadCount(10)

    # def process_result(self, rev):
    #     # print 'Receiving', rev
    #     self.ref.setText(rev)

    def start(self):
        self.factory = GenerWork(self.ar)

        self.factory.generateWorkers()
        workers = self.factory.get_workers()

        # print workers
        for worker in workers:
            worker.signals.result.connect(self.process_result)

            self.pool.start(worker)

        self.pool.waitForDone()
        return data

    def get_shell_data(self):
        return self.factory.get_shell_data()
开发者ID:sunsray,项目名称:syn_tool,代码行数:31,代码来源:StayRatioTask.py

示例2: start

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import setMaxThreadCount [as 别名]
    def start(self):
        self.idmap = {}
        self.entries = []

        pool = QThreadPool()
        pool.setMaxThreadCount(1)

        for label in LABELS:
            feed = Feed(label, self)
            pool.start(feed)
            imap = Imap(label, self)
            pool.start(imap)

        pool.waitForDone()
        self.done.emit()
开发者ID:gen2brain,项目名称:gmailcheck,代码行数:17,代码来源:gmailcheck.py

示例3: KISS_Thread

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import setMaxThreadCount [as 别名]
class KISS_Thread(QtCore.QThread):
    """
        AX.25 Communication
    """
    packet_received = pyqtSignal("QString", name="packetReceived")

    def __init__(self, control_system):
        """Make a instance of the ReaderAndWriterThread class.
        Args:
            protocol (SerialProtocol): It is a instance of a communication protocol.
        """
        QThread.__init__(self, control_system)
        self.writer_thread = QThreadPool(self)
        self.writer_thread.setMaxThreadCount(1)

    def run(self):
        print "kiss started"
        self.kiss_connect()

    def read_callback(self, data):
        print "received packet, len", len(data)
        kiss_data = kiss.constants.FEND + kiss.util.escape_special_codes(data) + kiss.constants.FEND
        log_the_data("./log_files/telemetry_log_files/BSU_satellite.kss", kiss_data)
        data = data[1:]
        if len(data) < 15:
            print "bad packet"
            return
        dest = "".join([chr(ord(c) >> 1) for c in data[:6]])
        # print "Destination", dest
        src = "".join([chr(ord(c) >> 1) for c in data[7:13]])
        #print "Source", src
        if not dest.startswith(LOCAL_SSID):
            print "packet not for us"
            return
        start = 16
        ssid = ord(data[13]) & 1
        if ssid == 0:
            via = "".join([chr(ord(c) >> 1) for c in data[7:13]])
            start = 23
        size = len(data) - start
        if size == 0:
            print "packet is empty"
            return
        payload = data[start:]
        # self.control_system.on_packet_received(payload)
        self.packet_received.emit(payload)

    def kiss_connect(self):
        try:
            print "connect"
            self.kiss_prot = kiss.KISS(port=config.kiss_serial_name, speed=config.kiss_baudrate)
            self.kiss_prot.start()
            self.kiss_prot.read(self.read_callback)
        except:
            error_mesage = "CANNOT OPEN PORT"
            log_the_error(error_mesage)
            sound.play(error_mesage)

            print sys.exc_info()
            print "ax.25 is failed"


    def send_command(self, name, arg, device, time_of_execution):
        data = {
            "Timestamp": int(time.time()),
            "Schedule": time_of_execution,
            "Cmd": name,
            "Arg": arg,
            "Device": device
        }
        json_data = json.dumps(data)

        print "Formed packet", json_data
        writer = KissWriter(self.kiss_prot, LOCAL_SSID, REMOTE_SSID)
        writer.set_data(json_data)
        self.writer_thread.start(writer)
开发者ID:andrei-volkau,项目名称:ground_station,代码行数:78,代码来源:KISS_Thread.py

示例4: MainWindow

# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import setMaxThreadCount [as 别名]
class MainWindow(QtGui.QMainWindow):

    """
    Main window for the application

    Takes Ui_MainWindow from mainUI.py, which is automatically generated
    with pyuic4 from the UI file.
    """

    def __init__(self, parent=None):
        """Init Window"""
        QtGui.QMainWindow.__init__(self, parent)
        self.gui = Ui_MainWindow()
        self.gui.setupUi(self)
        self.gscriptpath = '"' +  os.getcwd() + r'\gs\gs9.02\bin'
        self.gui.progressBar.hide()
        self.single_output_dir = ''
        self.deletions = []
        self.work = QThreadPool()
        self.work.setMaxThreadCount(1)
        self.thread_number = 5
        self.setWindowIcon(QtGui.QIcon(":/ico.png"))
        self.resolution = 450
        self.mode = 'tiffg4'


    def quit(self):

        """
        Quit the window, in case we need some specific behaviour
        """

        print self


    def dir_locate(self):
        """
        Will locate a dir to split all pdfs
        """
        pass


    def dir_output(self):
        """
        Will locate an output dir for dir conversion
        """
        pass


    def single_output_file(self):

        """
        Spawns a find file dialog
        """
        # get a local ref to dialog
        dir_dialog = QtGui.QFileDialog(self)
        # set dialog type
        dir_dialog.setFileMode(QtGui.QFileDialog.Directory)

        # if the dialog is 'executed' (hit ok)
        # then we take the string into a class attrib
        if dir_dialog.exec_() == True:
            for item in dir_dialog.selectedFiles():
                self.single_output_dir = item
                self.gui.single_line_out.setText(item)
                break


    def single_locate_file(self):

        """
        creates a dialog to find a single file
        """

        # Create the file lookup dialog using built-in dialogs
        # We set the file type to PDF and only PDF
        self.gui.single_line_in.setText(QtGui.QFileDialog.getOpenFileName(
                                       self, 'Open', '' ,('PDF Files (*.pdf)')))


    def update_progress_bar(self):

        """
        Method to update progress bar whilst running conversion
        """

        # When we get a call it's from a thread finishing
        # we increment the progress bar and check if we're at 100%
        self.gui.progressBar.setValue(self.gui.progressBar.value()+1)

        # This is bad, if a QProcess fails, we don't get a tick
        # and the progressBar will never get to 100%
        # we need to implement something that will catch errors with
        # QProcess
        if self.gui.progressBar.value() == self.gui.progressBar.maximum():
            self.gui.progressBar.hide()

            # create the deleter thread with a reference to the deletions
            # list.
            deleter = QFileWorker(self.deletions, self)
#.........这里部分代码省略.........
开发者ID:AeroNotix,项目名称:pdftotif,代码行数:103,代码来源:main.py


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