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


Python queue.PriorityQueue方法代码示例

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


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

示例1: __init__

# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self, thread_manager, thread_count=10):
        """Initialization method

        :param thread_manager: the thread manager to use
        :param thread_count: the number of workers to instantiate
        """
        self.logger = logging.getLogger(
            'storj.downstream_farmer.utils.ThreadPool')
        self.tasks = PriorityQueue()
        self.thread_manager = thread_manager
        self.workers = list()
        self.workers_lock = threading.Lock()
        self.max_thread_count = 50
        self.load_minimum = 0.01
        self.load_maximum = 0.5
        # managed monitor thread
        self.monitor_thread = self.thread_manager.create_thread(
            name='MonitorThread',
            target=self._monitor)
        for i in range(0, thread_count):
            self._add_thread() 
开发者ID:StorjOld,项目名称:downstream-farmer,代码行数:23,代码来源:utils.py

示例2: __init__

# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self):
        super(PushThread, self).__init__()
        self.queue = PriorityQueue()
        self.setDaemon(True) 
开发者ID:rizar,项目名称:attention-lvcsr,代码行数:6,代码来源:plot.py

示例3: __init__

# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self, progress, *args, **kwargs):
    Queue.PriorityQueue.__init__(self, *args, **kwargs)
    self.progress = progress 
开发者ID:luci,项目名称:luci-py,代码行数:5,代码来源:threading_utils.py

示例4: __init__

# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self):
        self.timers = queue.PriorityQueue() 
开发者ID:faicker,项目名称:greendns,代码行数:4,代码来源:timer.py

示例5: __init__

# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self, session, document):
        self.session = session
        self.document = document
        super(PushThread, self).__init__()
        self.queue = PriorityQueue()
        self.setDaemon(True) 
开发者ID:mila-iqia,项目名称:blocks-extras,代码行数:8,代码来源:plot.py

示例6: __init__

# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self, image, target=None, seed_vox=None, mask=None, sparse_mask=False, block_padding=None):
        self.block_padding = block_padding
        self.MOVE_DELTA = CONFIG.model.move_step
        self.queue = queue.PriorityQueue()
        self.visited = set()
        self.image = image
        self.bounds = np.array(image.shape, dtype=np.int64)
        if seed_vox is None:
            self.MOVE_GRID_OFFSET = np.array([0, 0, 0], dtype=np.int64)
        else:
            self.MOVE_GRID_OFFSET = np.mod(seed_vox, self.MOVE_DELTA).astype(np.int64)
        self.move_bounds = (
            np.ceil(np.true_divide((CONFIG.model.input_fov_shape - 1) // 2 - self.MOVE_GRID_OFFSET,
                                   self.MOVE_DELTA)).astype(np.int64),
            self.vox_to_pos(np.array(self.bounds) - 1 - (CONFIG.model.input_fov_shape - 1) // 2),
            )
        self.move_check_thickness = CONFIG.model.move_check_thickness
        if mask is None:
            if isinstance(self.image, OctreeVolume):
                self.mask = OctreeVolume(self.image.leaf_shape, (np.zeros(3), self.bounds), 'float32')
                self.mask[:] = np.NAN
            elif sparse_mask:
                self.mask = OctreeVolume(CONFIG.model.training_subv_shape, (np.zeros(3), self.bounds), 'float32')
                self.mask[:] = np.NAN
            else:
                self.mask = np.full(self.bounds, np.NAN, dtype=np.float32)
        else:
            self.mask = mask
        self.target = target

        self.bias_against_merge = False
        self.move_based_on_new_mask = False
        self.prioritize_proximity = CONFIG.model.move_priority == 'proximity'
        self.proximity = {}

        if seed_vox is None:
            seed_pos = np.floor_divide(self.move_bounds[0] + self.move_bounds[1], 2)
        else:
            seed_pos = self.vox_to_pos(seed_vox)
            assert self.pos_in_bounds(seed_pos), \
                'Seed position (%s) must be in region move bounds (%s, %s).' % \
                (seed_vox, self.move_bounds[0], self.move_bounds[1])
        self.seed_pos = seed_pos
        self.queue.put((None, seed_pos))
        self.proximity[tuple(seed_pos)] = 1
        self.seed_vox = self.pos_to_vox(seed_pos)
        if self.target is not None:
            self.target_offset = (self.bounds - self.target.shape) // 2
            assert np.isclose(self.target[tuple(self.seed_vox - self.target_offset)], CONFIG.model.v_true), \
                'Seed position should be in target body.'
        self.mask[tuple(self.seed_vox)] = CONFIG.model.v_true
        self.visited.add(tuple(self.seed_pos)) 
开发者ID:aschampion,项目名称:diluvian,代码行数:54,代码来源:regions.py


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