Python six.moves.queue.PriorityQueue() Examples
The following are 6
code examples of six.moves.queue.PriorityQueue().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
six.moves.queue
, or try the search function
.
Example #1
Source File: utils.py From downstream-farmer with MIT License | 6 votes |
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()
Example #2
Source File: plot.py From attention-lvcsr with MIT License | 5 votes |
def __init__(self): super(PushThread, self).__init__() self.queue = PriorityQueue() self.setDaemon(True)
Example #3
Source File: threading_utils.py From luci-py with Apache License 2.0 | 5 votes |
def __init__(self, progress, *args, **kwargs): Queue.PriorityQueue.__init__(self, *args, **kwargs) self.progress = progress
Example #4
Source File: timer.py From greendns with MIT License | 5 votes |
def __init__(self): self.timers = queue.PriorityQueue()
Example #5
Source File: plot.py From blocks-extras with MIT License | 5 votes |
def __init__(self, session, document): self.session = session self.document = document super(PushThread, self).__init__() self.queue = PriorityQueue() self.setDaemon(True)
Example #6
Source File: regions.py From diluvian with MIT License | 4 votes |
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))