當前位置: 首頁>>代碼示例>>Python>>正文


Python Queue.Full方法代碼示例

本文整理匯總了Python中Queue.Full方法的典型用法代碼示例。如果您正苦於以下問題:Python Queue.Full方法的具體用法?Python Queue.Full怎麽用?Python Queue.Full使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Queue的用法示例。


在下文中一共展示了Queue.Full方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sendHciCommand

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def sendHciCommand(self, opcode, data, timeout=2):
        """
        Send an arbitrary HCI packet by pushing a send-task into the
        sendQueue. This function blocks until the response is received
        or the timeout expires. The return value is the Payload of the
        HCI Command Complete Event which was received in response to
        the command or None if no response was received within the timeout.
        """

        queue = Queue.Queue(1)
        try:
            self.sendQueue.put((opcode, data, queue), timeout=timeout)
            return queue.get(timeout=timeout)
        except Queue.Empty:
            log.warn("sendHciCommand: waiting for response timed out!")
            return None
        except Queue.Full:
            log.warn("sendHciCommand: send queue is full!")
            return None 
開發者ID:francozappa,項目名稱:knob,代碼行數:21,代碼來源:core.py

示例2: put

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def put(self, item, block=True, timeout=None):
    """Put an item into the requeue.

    Args:
      item: An item to add to the requeue.
      block: Whether to block if the requeue is full.
      timeout: Maximum on how long to wait until the queue is non-full.

    Raises:
      Queue.Full if the queue is full and the timeout expires.
    """
    def PutAction():
      self.queue.put(item, block=False)
    self._DoWithTimeout(PutAction,
                        Queue.Full,
                        self.get_cond,
                        self.put_cond,
                        self.lock,
                        timeout=timeout,
                        block=block) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:22,代碼來源:requeue.py

示例3: reput

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def reput(self, item, block=True, timeout=None):
    """Re-put an item back into the requeue.

    Re-putting an item does not increase the number of outstanding
    tasks, so the reput item should be uniquely associated with an
    item that was previously removed from the requeue and for which
    TaskDone has not been called.

    Args:
      item: An item to add to the requeue.
      block: Whether to block if the requeue is full.
      timeout: Maximum on how long to wait until the queue is non-full.

    Raises:
      Queue.Full is the queue is full and the timeout expires.
    """
    def ReputAction():
      self.requeue.put(item, block=False)
    self._DoWithTimeout(ReputAction,
                        Queue.Full,
                        self.get_cond,
                        self.put_cond,
                        self.lock,
                        timeout=timeout,
                        block=block) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:27,代碼來源:requeue.py

示例4: _queue_connection

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def _queue_connection(self, cnx):
        """Put connection back in the queue

        This method is putting a connection back in the queue. It will not
        acquire a lock as the methods using _queue_connection() will have it
        set.

        Raises PoolError on errors.
        """
        if not isinstance(cnx, MySQLConnection):
            raise errors.PoolError(
                "Connection instance not subclass of MySQLConnection.")

        try:
            self._cnx_queue.put(cnx, block=False)
        except queue.Full:
            errors.PoolError("Failed adding connection; queue is full") 
開發者ID:LuciferJack,項目名稱:python-mysql-pool,代碼行數:19,代碼來源:dpooling.py

示例5: run

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def run(self):
        while True:
            resource = {}
            resource['url'] = '{0}{1}'.format(self.url, self.offset)
            resource['type'] = self.type
            try:
                self.q.put(resource, block=True, timeout=3)
            except Queue.Full:
                pass
            else:
                print '{0} now in queue'.format(self.offset)
                if self.offset < self.pages:
                    self.offset += 1
                else:
                    break
        print '{0} finish produce works'.format(self.name) 
開發者ID:bluedazzle,項目名稱:django-angularjs-blog,代碼行數:18,代碼來源:ProxyProducer.py

示例6: serve

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def serve(self, socket):
        echo_queue = queue.Queue(2)
        echo_thread = threading.Thread(target=self.echo,
                                       args=(socket, echo_queue))
        echo_thread.start()
        peer = socket.getpeername()
        log.info("serving connection from sap {0}".format(peer))
        while socket.poll("recv"):
            data = socket.recv()
            if data is None:
                break
            log.info("rcvd {0} byte from sap {1}".format(len(data), peer))
            if echo_queue.full():
                socket.setsockopt(nfc.llcp.SO_RCVBSY, True)
            echo_queue.put(data)
        log.info("remote peer {0} closed closed connection".format(peer))
        try:
            echo_queue.put_nowait(int(0))
        except queue.Full:
            pass
        echo_thread.join()
        socket.close()
        log.info("serve thread terminated") 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:25,代碼來源:llcp-test-server.py

示例7: add_event_to_queue

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def add_event_to_queue(self, event_type, event_data, player_state):
        """Adds an event in the queue of events to be processed"""
        videoid = common.VideoId.from_dict(event_data['videoid'])
        # pylint: disable=unused-variable
        previous_data, previous_player_state = self.cache_data_events.get(videoid.value, ({}, None))
        manifest = get_manifest(videoid)
        url = manifest['links']['events']['href']

        if previous_data.get('xid') in self.banned_events_ids:
            common.warn('EVENT [{}] - Not added to the queue. The xid {} is banned due to a previous failed request',
                        event_type, previous_data.get('xid'))
            return

        from resources.lib.services.msl.msl_request_builder import MSLRequestBuilder
        request_data = MSLRequestBuilder.build_request_data(url,
                                                            self._build_event_params(event_type,
                                                                                     event_data,
                                                                                     player_state,
                                                                                     manifest))
        try:
            self.queue_events.put_nowait(Event(request_data, event_data))
        except queue.Full:
            common.warn('EVENT [{}] - Not added to the queue. The event queue is full.', event_type) 
開發者ID:CastagnaIT,項目名稱:plugin.video.netflix,代碼行數:25,代碼來源:events_handler.py

示例8: _proc_loop

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def _proc_loop(proc_id, alive, queue, fn):
        """
        Thread loop for generating data

        Parameters
        ----------
        proc_id: int
            Process id
        alive: multiprocessing.Value
            variable for signaling whether process should continue or not
        queue: multiprocessing.Queue
            queue for passing data back
        fn: function
            function object that returns a sample to be pushed into the queue
        """
        print("proc {} started".format(proc_id))
        try:
            while alive.value:
                data = fn()
                put_success = False
                while alive.value and not put_success:
                    try:
                        queue.put(data, timeout=0.5)
                        put_success = True
                    except QFullExcept:
                        # print("Queue Full")
                        pass
        except KeyboardInterrupt:
            print("W: interrupt received, stopping process {} ...".format(proc_id))
        print("Closing process {}".format(proc_id))
        queue.close() 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:33,代碼來源:multiproc_data.py

示例9: add_nameserver

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def add_nameserver(self, nameserver):
        keep_trying = True
        while not self.time_to_die and keep_trying:
            try:
                self.resolver_q.put(nameserver, timeout = 1)
                trace("Added nameserver:", nameserver)
                keep_trying = False
            except Exception as e:
                if type(e) == Queue.Full or str(type(e)) == "<class 'queue.Full'>":
                    keep_trying = True 
開發者ID:kp625544,項目名稱:subtake,代碼行數:12,代碼來源:subbrute.py

示例10: _put_conn

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def _put_conn(self, conn):
        """
        Put a connection back into the pool.

        :param conn:
            Connection object for the current host and port as returned by
            :meth:`._new_conn` or :meth:`._get_conn`.

        If the pool is already full, the connection is closed and discarded
        because we exceeded maxsize. If connections are discarded frequently,
        then maxsize should be increased.

        If the pool is closed, then the connection will be closed and discarded.
        """
        try:
            self.pool.put(conn, block=False)
            return  # Everything is dandy, done.
        except AttributeError:
            # self.pool is None.
            pass
        except Full:
            # This should never happen if self.block == True
            log.warning(
                "Connection pool is full, discarding connection: %s" %
                self.host)

        # Connection never got put back into the pool, close it.
        if conn:
            conn.close() 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:31,代碼來源:connectionpool.py

示例11: __exit__

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def __exit__(self, extype, exvalue, traceback):
        # if we had a MySQL related error we try to rollback the cursor.
        if extype is mysql.MySQLError:
            self.cursor.rollback()

        self.cursor.close()
        self.conn.commit()

        # Put it back on the queue
        try:
            self._cache.put_nowait(self.conn)
        except Queue.Full:
            self.conn.close() 
開發者ID:CwbhX,項目名稱:Jamais-Vu,代碼行數:15,代碼來源:database_sql.py

示例12: _put_conn

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def _put_conn(self, conn):
        """
        Put a connection back into the pool.

        :param conn:
            Connection object for the current host and port as returned by
            :meth:`._new_conn` or :meth:`._get_conn`.

        If the pool is already full, the connection is closed and discarded
        because we exceeded maxsize. If connections are discarded frequently,
        then maxsize should be increased.

        If the pool is closed, then the connection will be closed and discarded.
        """
        try:
            self.pool.put(conn, block=False)
            return  # Everything is dandy, done.
        except AttributeError:
            # self.pool is None.
            pass
        except Full:
            # This should never happen if self.block == True
            log.warning(
                "Connection pool is full, discarding connection: %s",
                self.host)

        # Connection never got put back into the pool, close it.
        if conn:
            conn.close() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:31,代碼來源:connectionpool.py

示例13: SubmitItem

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def SubmitItem(self, item, block=True, timeout=0.0):
    """Submit a WorkItem to the AdaptiveThreadPool.

    Args:
      item: A WorkItem instance.
      block: Whether to block on submitting if the submit queue is full.
      timeout: Time wait for room in the queue if block is True, 0.0 to
        block indefinitely.

    Raises:
      Queue.Full if the submit queue is full.
    """
    self.requeue.put(item, block=block, timeout=timeout) 
開發者ID:elsigh,項目名稱:browserscope,代碼行數:15,代碼來源:adaptive_thread_pool.py

示例14: _put_conn

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def _put_conn(self, conn):
        """
        Put a connection back into the pool.

        :param conn:
            Connection object for the current host and port as returned by
            :meth:`._new_conn` or :meth:`._get_conn`.

        If the pool is already full, the connection is closed and discarded
        because we exceeded maxsize. If connections are discarded frequently,
        then maxsize should be increased.

        If the pool is closed, then the connection will be closed and discarded.
        """
        try:
            self.pool.put(conn, block=False)
            return # Everything is dandy, done.
        except AttributeError:
            # self.pool is None.
            pass
        except Full:
            # This should never happen if self.block == True
            log.warning(
                "Connection pool is full, discarding connection: %s" %
                self.host)

        # Connection never got put back into the pool, close it.
        if conn:
            conn.close() 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:31,代碼來源:connectionpool.py

示例15: FindAllUids

# 需要導入模塊: import Queue [as 別名]
# 或者: from Queue import Full [as 別名]
def FindAllUids(self,htmlContent,surfedUid,uidQueue,fp1):
        print('In Find All uids')#action-type=\"follow\" action-data=\"refer_sort=followlist&refer_flag=followlist&uid=
        PatUid=re.compile('(<li class=\\\\"follow_item S_line2\\\\" action-type=\\\\"itemClick\\\\" action-data=\\\\"uid=)(\\d+)'.encode('utf8'))
        for m in PatUid.finditer(htmlContent):
            mUid=m.group(2)
            #print mUid
            if mUid not in surfedUid:
                if uidQueue.put(mUid,True)==Queue.Full:
                    print("The urlQueue is Full,Stop spiding")
                    return
                fp1.write('  '.encode('utf8')+mUid)
        PatNextPage=re.compile('(<a bpfilter=\\\\"page\\\\" class=\\\\"page next S_txt1 S_line1\\\\" href=\\\\")(\\\\/p\\\\/\\d+\\\\/.*)("><span>下一頁<\\\\/span><\\\\/a>)'.decode('gbk').encode('utf8'))

        result=PatNextPage.search(htmlContent)

        while result!=None:#存在下一頁
            print("Next Page")#係統問題,新浪微博規定隻能瀏覽5頁
            
            result=result.group(2)
            result=re.sub('\\\\','',result)
            result='http://weibo.com'+result

            time.sleep(1)
            htmlContent=urllib2.urlopen(result).read()

            PatUid=re.compile('(<li class=\\\\"follow_item S_line2\\\\" action-type=\\\\"itemClick\\\\" action-data=\\\\"uid=)(\\d+)'.encode('utf8'))
            PatUid.search(htmlContent)
            for m in PatUid.finditer(htmlContent):
                #print mUid
                mUid=m.group(2)
                if mUid not in surfedUid:
                    if uidQueue.put(mUid,True)==Queue.Full:
                        print("The urlQueue is Full,Stop spiding")
                        return
                    fp1.write('  '.encode('utf8')+mUid)
            result=PatNextPage.search(htmlContent) 
開發者ID:somethingx64,項目名稱:SinaMicroblog_Creeper-Spider_VerificationCode,代碼行數:38,代碼來源:weibospider.py


注:本文中的Queue.Full方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。