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


Python queue.LifoQueue方法代码示例

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


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

示例1: test_subscribe_transactions

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def test_subscribe_transactions(self, alice):
        gen_and_sync_lnd(alice.bitcoin, [alice])
        subscription = alice.subscribe_transactions()
        alice.add_funds(alice.bitcoin, 1)
        assert isinstance(subscription, grpc._channel._Rendezvous)
        assert isinstance(subscription.__next__(), rpc_pb2.Transaction)

        # gen_and_sync_lnd(alice.bitcoin, [alice])
        # transaction_updates = queue.LifoQueue()
        #
        # def sub_transactions():
        #     try:
        #         for response in alice.subscribe_transactions():
        #             transaction_updates.put(response)
        #     except StopIteration:
        #         pass
        #
        # alice_sub = threading.Thread(target=sub_transactions(), daemon=True)
        # alice_sub.start()
        # time.sleep(1)
        # while not alice_sub.is_alive():
        #     time.sleep(0.1)
        # alice.add_funds(alice.bitcoin, 1)
        #
        # assert any(isinstance(update) == rpc_pb2.Transaction for update in get_updates(transaction_updates)) 
开发者ID:willcl-ark,项目名称:lnd_grpc,代码行数:27,代码来源:test.py

示例2: test_subscribe_channel_events

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def test_subscribe_channel_events(self, bitcoind, bob, carol):
        bob, carol = setup_nodes(bitcoind, [bob, carol])
        gen_and_sync_lnd(bitcoind, [bob, carol])
        chan_updates = queue.LifoQueue()

        def sub_channel_events():
            try:
                for response in bob.subscribe_channel_events():
                    chan_updates.put(response)
            except grpc._channel._Rendezvous:
                pass

        bob_sub = threading.Thread(target=sub_channel_events, daemon=True)
        bob_sub.start()
        time.sleep(1)
        while not bob_sub.is_alive():
            time.sleep(0.1)
        channel_point = bob.list_channels()[0].channel_point

        bob.close_channel(channel_point=channel_point).__next__()
        generate(bitcoind, 3)
        gen_and_sync_lnd(bitcoind, [bob, carol])
        assert any(
            update.closed_channel is not None for update in get_updates(chan_updates)
        ) 
开发者ID:willcl-ark,项目名称:lnd_grpc,代码行数:27,代码来源:test.py

示例3: find_index

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def find_index(self, value, starting_node=0):
        """Find the index of the first node that matches value in a BFS

        Performs a breadth-first search of the graph starting at node index
        starting_node.  Returns the index or None if no match is found

        Args:
            value(Node Value) - Value to match against in the graph
            starting_node(int) - Node index to start search from
        """
        if starting_node > self.node_count():
            raise IndexError("Node ID out of range.")

        node_queue = queue.LifoQueue()
        node_queue.put(starting_node)
        visited = [starting_node]
        while not node_queue.empty():
            next_id = node_queue.get()
            if (self.nodes[next_id].value == value):
                return next_id  # Success
            for uid in self.neighbors[next_id]:
                if (self.uid_to_index[uid] not in visited):
                    node_queue.put(self.uid_to_index[uid])
                    visited += [self.uid_to_index[uid]]
        return None 
开发者ID:quantumlib,项目名称:OpenFermion-ProjectQ,代码行数:27,代码来源:_graph.py

示例4: ispar

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def ispar(s):
    # code here
    import queue
    stack = queue.LifoQueue()
    
    for i in range(len(s)):
        if ((s[i] == '{') | (s[i] == '[') | (s[i] == '(')):
            stack.put(s[i])
        if ((s[i] == '}') | (s[i] == ']') | (s[i] == ')')):
            if stack.empty():
                return False
            elif not isMatchingPair(stack.get(),s[i]):
                return False
        
    if stack.empty():
        return True
    else:
        return False 
开发者ID:absognety,项目名称:DSA-GeeksClasses,代码行数:20,代码来源:parenthesisChecker.py

示例5: __init__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __init__(self, host=DEFAULT_LISTEN_HOST, port=DEFAULT_LISTEN_PORT, ssl_context: Optional[SSLContext] = None,
                 default_waiting_settings: Optional[WaitingSettings] = None):
        """
        Initializes the instance.

        """
        self.host = host
        self.port = port
        self.server = None
        self.server_thread = None
        self.assertions = []
        self.log = []
        self.ordered_handlers = []
        self.oneshot_handlers = RequestHandlerList()
        self.handlers = RequestHandlerList()
        self.permanently_failed = False
        self.ssl_context = ssl_context
        if default_waiting_settings is not None:
            self.default_waiting_settings = default_waiting_settings
        else:
            self.default_waiting_settings = WaitingSettings()
        self._waiting_settings = copy(self.default_waiting_settings)
        self._waiting_result = queue.LifoQueue(maxsize=1) 
开发者ID:csernazs,项目名称:pytest-httpserver,代码行数:25,代码来源:httpserver.py

示例6: __init__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __init__(self):
        super().__init__()
        self._handling_lock = Lock()
        self._teardown_callback_stack = LifoQueue()  # we execute callbacks in the reverse order that they were added
        self._logger = log.get_logger(__name__)
        self._handled_exceptions = Queue()
        self._teardown_callback_raised_exception = False

        # Set up handlers to be called when the application process receives certain signals.
        # Note: this will raise if called on a non-main thread, but we should NOT work around that here. (That could
        # prevent the teardown handler from ever being registered!) Calling code should be organized so that this
        # singleton is only ever initialized on the main thread.
        signal.signal(signal.SIGTERM, self._application_teardown_signal_handler)
        signal.signal(signal.SIGINT, self._application_teardown_signal_handler)
        try:
            signal.signal(process_utils.SIGINFO, self._application_info_dump_signal_handler)
        except ValueError:
            self._logger.warning('Failed to register signal handler for SIGINFO. This is expected if ClusterRunner '
                                 'is running on Windows.') 
开发者ID:box,项目名称:ClusterRunner,代码行数:21,代码来源:unhandled_exception_handler.py

示例7: __init__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __init__(self, mode):
        self.mode = mode
        self.conf = capture_conf.env[mode]
        self.init_sources(self.conf.source_paths)
        self.detector = Predict.instance()
        self.trackers = [Tracker(nn_matching.NearestNeighborDistanceMetric("cosine", self.conf.track_max_cosine_distance, self.conf.track_nn_budget),
                                 max_iou_distance=self.conf.track_max_iou_distance,
                                 max_age=self.conf.track_max_age,
                                 n_init=self.conf.track_n_init)
                         for _ in self.sources_parsed]
        self.track_pool = new_pools(self.conf.pool_size)
        self.save_pool = new_pools(self.conf.pool_size)
        self.frame_index = 0
        self.video_state = False
        if self.conf.video_on:
            self.box_queue = queue.LifoQueue(100)
            if self.conf.is_async:
                submit(self.video_on)
        self.debug = mode == 'dev'
        if self.debug:
            self.last_time = datetime.now()
            self.fps = 0
            self.pids = set() 
开发者ID:Kestrong,项目名称:capture_reid,代码行数:25,代码来源:main.py

示例8: __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

示例9: test_subscribe_invoices

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def test_subscribe_invoices(self, alice):
        """
        Invoice subscription run as a thread
        """
        gen_and_sync_lnd(alice.bitcoin, [alice])
        invoice_updates = queue.LifoQueue()

        def sub_invoices():
            try:
                for response in alice.subscribe_invoices():
                    invoice_updates.put(response)
            except grpc._channel._Rendezvous:
                pass

        alice_sub = threading.Thread(target=sub_invoices, daemon=True)
        alice_sub.start()
        time.sleep(1)
        while not alice_sub.is_alive():
            time.sleep(0.1)
        alice.add_invoice(value=SEND_AMT)
        alice.daemon.wait_for_log("AddIndex")
        time.sleep(0.1)

        assert any(
            isinstance(update, rpc_pb2.Invoice)
            for update in get_updates(invoice_updates)
        ) 
开发者ID:willcl-ark,项目名称:lnd_grpc,代码行数:29,代码来源:test.py

示例10: __init__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __init__(self, configs, stopper: threading.Event):
        super().__init__()
        self.configs = configs
        self.stopper = stopper
        self.input_q = LifoQueue()
        self.output_q = LifoQueue() 
开发者ID:QuarkChain,项目名称:pyquarkchain,代码行数:8,代码来源:external_miner.py

示例11: removePair

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def removePair(s):
    # code here
    import queue
    stack = queue.LifoQueue()
    r = ''
    stack.put(s[0])
    for i in range(1,len(s)):
        if stack.empty():
            stack.put(s[i])
        else:
            f = stack.get()
            if f != s[i]:
                stack.put(f)
                stack.put(s[i])
            else:
                stack.put(f)
                g = stack.get()
                if g == s[i]:
                    pass
    while (stack.empty() is not True):
        x = stack.get()
        r = x + r
    if r != '':
        return r
    else:
        return "Empty String" 
开发者ID:absognety,项目名称:DSA-GeeksClasses,代码行数:28,代码来源:removeConsecutiveDuplicatePairs.py

示例12: _create_session_pool

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def _create_session_pool(self):
        # Create a pool to reuse sessions containing connections to the server
        session_pool = LifoQueue()
        for _ in range(self._session_pool_size):
            session_pool.put(self.create_session(), block=False)
        return session_pool 
开发者ID:ecederstrand,项目名称:exchangelib,代码行数:8,代码来源:protocol.py

示例13: __iter__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __iter__(self):
        stack = LifoQueue()
        for element in self._iterable:
            stack.put(element)
        while not stack.empty():
            yield stack.get() 
开发者ID:viralogic,项目名称:py-enumerable,代码行数:8,代码来源:py_linq.py

示例14: __init__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __init__(self, playerManager):
        self.playerManager = playerManager

        self.is_menu_shown = False
        self.menu_title = ""
        self.menu_stack = LifoQueue()
        self.menu_list = []
        self.menu_selection = 0
        self.menu_tmp = None
        self.original_osd_color = playerManager._player.osd_back_color
        self.original_osd_size = playerManager._player.osd_font_size

    # The menu is a bit of a hack...
    # It works using multiline OSD.
    # We also have to force the window to open. 
开发者ID:iwalton3,项目名称:plex-mpv-shim,代码行数:17,代码来源:menu.py

示例15: __init__

# 需要导入模块: import queue [as 别名]
# 或者: from queue import LifoQueue [as 别名]
def __init__(self):
        self.db = Database(MONGODB)
        self.ID_queue = queue.LifoQueue() 
开发者ID:01ly,项目名称:TTBot,代码行数:5,代码来源:grabber.py


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