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


Python Pool.daemon方法代码示例

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


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

示例1: _multiprocess_files

# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import daemon [as 别名]
    def _multiprocess_files(self):
        '''Creates a pool to run through several files at once'''

        pool = Pool(processes=self._optional_params[LSC.PROCESSOR_COUNT])
        pool.daemon = True

        # First copy any remote files as needed and create final file list
        if (self._user_params.get(LSC.LEVEL, None)
                and not self._are_logs_archived(self._user_params.get(LSC.DATE, None))):
            if (self._optional_params.get(LSC.FORCE_COPY, False)
                or socket.gethostname() != self._get_box_from_level(self._user_params.get(LSC.LEVEL, None))):
                file_list = pool.map(self._get_log_file, self._file_list)
                pool.close()
                pool.join()
                self._file_list = sorted(filter(lambda x: x != '', file_list))

        LOGGER.debug('Final file list: %s', self._file_list)

        if self._file_list == []:
            LOGGER.error('No files found to process.')
            return None

        pool = Pool(processes=self._optional_params[LSC.PROCESSOR_COUNT])
        pool.daemon = True
        results = pool.map(self._process_file, self._file_list)
        pool.close()
        pool.join()
        return results
开发者ID:john-sterling,项目名称:LogScraper,代码行数:30,代码来源:base.py

示例2: asyn_load_batch_images

# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import daemon [as 别名]
def asyn_load_batch_images(args):
   params=args[0][0]
   pool = Pool(params["n_pool"])
   pool.daemon=True
   results = pool.map(load_batch_wrapper,args)
   pool.close()
   pool.join()
   return results
开发者ID:Seleucia,项目名称:CNNRNet,代码行数:10,代码来源:dt_utils.py

示例3: run_face_extraction

# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import daemon [as 别名]
def run_face_extraction(iterable, face_link, video_link):
    calibration = 95+27
    processes = args.processes
    pool = Pool(processes=processes, maxtasksperchild=100)
    pool.daemon = True
    skip = True
    files = [filename for filename in os.listdir(face_link)]
    id = [file[:24] for file in files]
    parsed = set(id)
    for i, item in enumerate(iterable):
        if str(item['_id']) == '58dd5bf05c4e323398440e60':
            skip = False
        if skip:
            print 'here', i
            continue
        if item['_id'] in parsed:
            print 'skipping'
            continue
        print 'now here', str(item['_id'])
        file_name = datetime.datetime.fromtimestamp(item['time']).strftime("%m-%d-%y_%H")
        door_id = item['door']
        file_name = video_link + door_id + '_' + file_name + '.avi'
        print i, item['door'], datetime.datetime.fromtimestamp(item['time']).strftime('%Y-%m-%d %H:%M:%S')
        print item['_id']
        if int(datetime.datetime.fromtimestamp(item['time']).strftime('%H')) > 22:
            continue
        d = datetime.datetime.fromtimestamp(item['time'])
        newdate = d.replace(minute=0, second=0).strftime('%s')
        event_time = int(item['time']) - int(newdate) - calibration
        if os.path.exists(file_name):
            cap = cv2.VideoCapture(file_name)
            length = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
            fps = length / 3600
            start = (event_time - 2.5) * fps
            end = (event_time + 2.5) * fps
            print length, start, end
            cap.set(1, start)
            photo_id = 1
            frames = []
            paths = []
            for _ in range(int(math.floor(start)), int(math.ceil(end))):
                # print 'here',
                grabbed, frame = cap.read()
                frames.append(frame)
                path = face_link + str(item['_id']) + '_' + str(photo_id) + '.png'
                paths.append(path)
                photo_id += 1
                if not grabbed:
                    print 'not grabbed'
                    break
            try:
                pars = zip(frames, paths)
                pool.map(getRep, pars)
            except Exception as e:
                print e
开发者ID:banacer,项目名称:door-wiz,代码行数:57,代码来源:face_extractor.py

示例4: len

# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import daemon [as 别名]
	fig.savefig(os.path.join(path_img_out2, img_name), dpi=200, bbox_inches='tight')
	plt.close(fig)
	print '%s: done' % img_name
	return

if __name__=="__main__":

	if len(sys.argv) == 2:
		layers = [int(sys.argv[1])]
	else:
		layers = [5,4,3,2,1]	

	tpl_info = template_info()
	
	p = Pool(8)
	p.daemon = True

	
	num_features = 64
	features = range(64)

	seg_idx = -1
	for layer in layers:
		for h_key in tpl_info.harmonic_keys:
			# multiprocessing doesn't work due to matplotlib/GUI/main_thread/etc..
			# args = zip(features, [tpl_info]*num_features, [h_key]*num_features, [layer]*num_features)
			# p.map(export_image, args)
			for feat in features:
				args= (feat, tpl_info, h_key, layer)
				export_image(args)
开发者ID:keunwoochoi,项目名称:Deconvolution,代码行数:32,代码来源:main_compare_images.py


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