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


Python Queue.LifoQueue方法代码示例

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


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

示例1: parenthesis

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def parenthesis(x):
        q=Queue.LifoQueue()
        p1={}
        p2={}

        for i in xrange(len(x)):
            if x[i] in ['(', '[', '{']:
                q.put(i);
                continue
            if x[i] in [')', ']', '}']:
                if(q.empty()==True):
                    return (None, None)
                k=q.get(False)
                p1[k]=i
                p2[i]=k
                continue

        return (p1, p2) 
开发者ID:empow,项目名称:logstash-parsers,代码行数:20,代码来源:pipeline_viewer.py

示例2: __init__

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def __init__(self, dataloder, batchSize=1, queueSize=1024):
        # initialize the file video stream along with the boolean
        # used to indicate if the thread should be stopped or not
        self.det_model = Darknet("yolo/cfg/yolov3-spp.cfg")
        self.det_model.load_weights('models/yolo/yolov3-spp.weights')
        self.det_model.net_info['height'] = opt.inp_dim
        self.det_inp_dim = int(self.det_model.net_info['height'])
        assert self.det_inp_dim % 32 == 0
        assert self.det_inp_dim > 32
        self.det_model.cuda()
        self.det_model.eval()

        self.stopped = False
        self.dataloder = dataloder
        self.batchSize = batchSize
        # initialize the queue used to store frames read from
        # the video file
        self.Q = LifoQueue(maxsize=queueSize) 
开发者ID:zh-plus,项目名称:video-to-pose3D,代码行数:20,代码来源:dataloader_webcam.py

示例3: __init__

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def __init__(self):
        self._queue = Queue.LifoQueue()
        self._failedque = deque()
        self._http_session = requests.Session()
        self._http_offline = False
        self._workers = [] 
开发者ID:bq,项目名称:web2board,代码行数:8,代码来源:telemetry.py

示例4: __init__

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def __init__(self):
		self.__version__ = "1.0"
		self.host_ip = ""
		self.host_port = 22
		self.usernames = Queue.LifoQueue()
		self.passwords = Queue.LifoQueue()
		self.password_list = []
		self.threads = 4
		self.timeout = 5 
开发者ID:d3vilbug,项目名称:Brutal_SSH,代码行数:11,代码来源:brutal_SSH.py

示例5: expand_all

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def expand_all(grammar, nonterm, state):
     result = ""
     queue = Queue.LifoQueue()
     queue.put_nowait(nonterm)
     # do this iteratively; recursively blows past python's recursive limit
     in_list = None
     len_at_start_of_list = 0
     while not queue.empty():
          head = queue.get_nowait()
          # Keep track of being in a list until all the bits for the list
          # have been used up
          if head in state.list_bits:
               in_list = head
               len_at_start_of_list = queue.qsize()
          # done with the list once we consume the next item in the queue
          if in_list and queue.qsize() < len_at_start_of_list:
               in_list = None
          terms = expand(grammar, head, state, in_list)
          if len(terms) == 0:
               if isinstance(head, basestring):
                    result = " ".join([result, head])
               else:
                    result = " ".join([result, str(head)])
          else :
               # put them into the lifo queue backwards, so we'll get the
               # first one out
               for nt in reversed(terms):
                    if nt in state.common.append_newlines():
                         queue.put_nowait(nltk.Nonterminal("\n"))
                    queue.put_nowait(nt)
     return result

# Must be determinstically reversible by the decoder, so use the
# following rules:
#  1) Erase spaces at the beginning and end of every line
#  2) If the first letter of the line is not capitalized, make it so
#  3) remove one space before all punctuation (except '(')
#  4) remove one space after '(' 
开发者ID:strib,项目名称:scipher,代码行数:40,代码来源:encode.py

示例6: _put_conn

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def _put_conn(self, host, port, sock):
        u""" 将连接添加回连接池

会检查连接状态,不正常的连接会被抛弃。

        """
        if hasattr(self.sock_mod, "get_display_name"):
            sock_name = self.sock_mod.get_display_name()
        else:
            sock_name = None
        sock_info = 'sock_mod:%s host:%s port:%s' % (sock_name, host, port)

        if sock:
            if is_connection_dropped(sock):
                logging.debug(u'已关闭连接无法添加回连接池。%s' % sock_info)
                try:
                    sock.close()
                except:
                    pass
            else:
                with self.lock:
                    site_connes = self.site_dict.get(u'%s:%s' % (host, port), None)
                    if site_connes is None:
                        site_connes = LifoQueue(self.max_site_conn)
                    try:
                        site_connes.put(sock)
                        logging.debug(u'添加连接回连接池。 %s' % sock_info)
                    except Full:
                        logging.debug(u'连接池满. %s' % sock_info)
                        try:
                            sock.close()
                        except:
                            pass
                        return
                    self.site_dict[u'%s:%s' % (host, port)] = site_connes 
开发者ID:GameXG,项目名称:TcpRoute,代码行数:37,代码来源:pool.py

示例7: __init__

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def __init__(self, webcam, queueSize=256):
        # initialize the file video stream along with the boolean
        # used to indicate if the thread should be stopped or not
        self.stream = cv2.VideoCapture(int(webcam))
        assert self.stream.isOpened(), 'Cannot capture source'
        self.stopped = False
        # initialize the queue used to store frames read from
        # the video file
        self.Q = LifoQueue(maxsize=queueSize) 
开发者ID:zh-plus,项目名称:video-to-pose3D,代码行数:11,代码来源:dataloader.py

示例8: set_urlnode_queue

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def set_urlnode_queue(self):
        if self.spider_policy == 1:
            self.spider_urlnode_queue = Queue.LifoQueue()
        elif self.spider_policy == 2:
            self.spider_urlnode_queue = Queue.PriorityQueue()
        else:
            self.spider_urlnode_queue = Queue.Queue() 
开发者ID:manning23,项目名称:MSpider,代码行数:9,代码来源:GlobalData.py

示例9: simple_queue_test

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def simple_queue_test(self, q):
        if not q.empty():
            raise RuntimeError, "Call this function with an empty queue"
        # I guess we better check things actually queue correctly a little :)
        q.put(111)
        q.put(333)
        q.put(222)
        target_order = dict(Queue = [111, 333, 222],
                            LifoQueue = [222, 333, 111],
                            PriorityQueue = [111, 222, 333])
        actual_order = [q.get(), q.get(), q.get()]
        self.assertEqual(actual_order, target_order[q.__class__.__name__],
                         "Didn't seem to queue the correct data!")
        for i in range(QUEUE_SIZE-1):
            q.put(i)
            self.assertTrue(not q.empty(), "Queue should not be empty")
        self.assertTrue(not q.full(), "Queue should not be full")
        last = 2 * QUEUE_SIZE
        full = 3 * 2 * QUEUE_SIZE
        q.put(last)
        self.assertTrue(q.full(), "Queue should be full")
        try:
            q.put(full, block=0)
            self.fail("Didn't appear to block with a full queue")
        except Queue.Full:
            pass
        try:
            q.put(full, timeout=0.01)
            self.fail("Didn't appear to time-out with a full queue")
        except Queue.Full:
            pass
        # Test a blocking put
        self.do_blocking_test(q.put, (full,), q.get, ())
        self.do_blocking_test(q.put, (full, True, 10), q.get, ())
        # Empty it
        for i in range(QUEUE_SIZE):
            q.get()
        self.assertTrue(q.empty(), "Queue should be empty")
        try:
            q.get(block=0)
            self.fail("Didn't appear to block with an empty queue")
        except Queue.Empty:
            pass
        try:
            q.get(timeout=0.01)
            self.fail("Didn't appear to time-out with an empty queue")
        except Queue.Empty:
            pass
        # Test a blocking get
        self.do_blocking_test(q.get, (), q.put, ('empty',))
        self.do_blocking_test(q.get, (True, 10), q.put, ('empty',)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:53,代码来源:test_queue.py

示例10: __init__

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def __init__(self, args):
        self.target_domain = args.domain
        self.cname_flag = args.cname
        if not (self.target_domain):
            print('usage: brutedns.py -h')
            sys.exit(1)

        self.check_env()
        self.level = args.level
        self.sub_dict = args.sub_file
        self.speed = args.speed
        self.default_dns = True if args.default_dns is "y" else False
        self.next_sub_dict = args.next_sub_file
        self.other_result = args.other_file

        self.timeout = 10
        self.resolver = dns.resolver.Resolver(configure=self.default_dns)
        self.resolver.lifetime = self.timeout
        self.resolver.timeout = self.timeout

        self.found_count = 0
        self.next_found_count = 0
        self.cmdline = ""
        self.queues = LifoQueue()
        self.queue_sub = Queue()
        self.cdn_set = set()
        self.cname_set = set()
        self.white_filter_subdomain = set()
        self.cname_block_dict = dict()
        self.ip_block_dict = dict()
        self.ip_all_dict = dict()
        self.ip_flag_dict = dict()
        self.active_ip_dict = dict()
        self.ip_count_dict = dict()
        self.black_ip = set()

        self.set_next_sub = self.load_next_sub_dict()
        self.set_cdn = self.load_cdn()

        self.load_sub_dict_to_queue()
        self.extract_next_sub_log()

        self.segment_num = self.judge_speed(self.speed)

        if not self.default_dns:
            self.nameservers = self.load_nameservers()
            self.check_nameservers() 
开发者ID:yanxiu0614,项目名称:subdomain3,代码行数:49,代码来源:brutedns.py

示例11: run_pipeline

# 需要导入模块: import Queue [as 别名]
# 或者: from Queue import LifoQueue [as 别名]
def run_pipeline(server_address, time_duration, process_real_time,
                 process_gaze, keep_frame_number, channel, area_of_interest,
                 fps,start_date,start_time,backend_params=None, 
                 file_params=None, profile=False):

    # initialize queues
    q = None
    if process_real_time:
        q = queue.LifoQueue()
    else:
        # queue size 1 for now
        q = queue.Queue(1)

    # initialize socket reader thread, this thread multiplexes multiple queues
    # for the sake of simplicity, it is one producer, multiple consumer design
    reader_thread = SocketReaderThread(q, server_address, keep_frame_number,
                                       profile)

    # initialize video consumers
    consumer_thread = ConsumerThread(q, process_real_time, process_gaze,
                                     channel, area_of_interest, fps,start_date,start_time,
                                     backend_params,file_params, profile)

    # start downstream (consumers)
    consumer_thread.start()

    # then, start upstream (producer)
    reader_thread.start()

    # run forever if duration is negative
    if time_duration < 0:
        # this only works python 3.2+ and on linux
        # threading.Event().wait()

        # wait for reader to finish
        reader_thread.join()

        # wait for consumer thread to finish
        consumer_thread.stop()
        consumer_thread.join()

    else:  # shutdown after time_duration seconds
        time.sleep(time_duration)

        # terminate upstream
        reader_thread.stop()

        # join the upstream
        reader_thread.join()

        # terminate downstream
        consumer_thread.stop()

        # join the downstream
        consumer_thread.join() 
开发者ID:edusense,项目名称:edusense,代码行数:57,代码来源:video_pipeline.py


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