本文整理汇总了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()
示例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)
示例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
示例4: __init__
# 需要导入模块: from six.moves import queue [as 别名]
# 或者: from six.moves.queue import PriorityQueue [as 别名]
def __init__(self):
self.timers = queue.PriorityQueue()
示例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)
示例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))