當前位置: 首頁>>代碼示例>>Python>>正文


Python threadpool.makeRequests方法代碼示例

本文整理匯總了Python中threadpool.makeRequests方法的典型用法代碼示例。如果您正苦於以下問題:Python threadpool.makeRequests方法的具體用法?Python threadpool.makeRequests怎麽用?Python threadpool.makeRequests使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在threadpool的用法示例。


在下文中一共展示了threadpool.makeRequests方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: work

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def work(self, iterJobFuncArgs, jobFunc, timeout=None):
        def argsGenerator():
            for jobFuncArgs in iterJobFuncArgs:
                self.results[hash(str(jobFuncArgs))] = {
                    'state': self.JOB_UNSTART,
                    'args': jobFuncArgs,
                }
                self.totalNum += 1
                yield ((jobFunc, jobFuncArgs), {})

        requests = tp.makeRequests(callable_=self._doJob,
                                   args_list=argsGenerator(),
                                   callback=self._cbJobFinished,
                                   exc_callback=self._cbHandleErr)
        [self.jobPool.putRequest(req) for req in requests]
        self.jobPool.wait()
        self.jobPool.dismissWorkers(self.concurrency, do_join=True)
        return self.results 
開發者ID:n0tr00t,項目名稱:Beehive,代碼行數:20,代碼來源:beethread.py

示例2: batchTest

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def batchTest(self, norm_target_func=None, *args, **kwds):
        '''
        the func must be the run() function in a poc class.
        '''
        def argsGenerator():
            func_args = {
                'options': self.options,
                'success': None,
                'poc_ret': {},
            }
            for seed in self.seed_iter:
                if norm_target_func:
                    func_args['options']['target'] = norm_target_func(seed.strip(), *args, **kwds)
                else:
                    func_args['options']['target'] = seed.strip()
                yield deepcopy(func_args)

        requests = threadpool.makeRequests(callable_=self.func2run,
                                           args_list = argsGenerator(),
                                           callback=self.cbSaveResult,
                                           exc_callback=self.cbHandleErr)
        [self.tp.putRequest(req) for req in requests]
        self.tp.wait()
        self.tp.dismissWorkers(100, do_join=True)
        return self.total_num, self.finished_num, self.err_num 
開發者ID:DavexPro,項目名稱:PocHunter,代碼行數:27,代碼來源:batchtest.py

示例3: mThreadExecute

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def mThreadExecute(self, threadcount=10,canexecute=True):
        import threadpool
        pool = threadpool.ThreadPool(threadcount)

        seed= parallel_map(self,canexecute);
        def Funcs(item):
            task= parallel_reduce(self,[item],canexecute);
            print('totalcount: %d'%len([r for r in task]));
            print('finish' + str(item));

        requests = threadpool.makeRequests(Funcs, seed);
        [pool.putRequest(req) for req in requests]
        pool.wait()
        # self.__close__() 
開發者ID:ferventdesert,項目名稱:etlpy,代碼行數:16,代碼來源:etl.py

示例4: run

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def run(self):
        #默認為10線程掃描
        pool = threadpool.ThreadPool(10) 

        #迭代任務隊列
        requests = threadpool.makeRequests(self.call_scan,self.list_renwu) 
        print 'add pool ok'
        for req in requests:
            pool.putRequest(req)
            print '---------------------ok----------------------'
        pool.wait() 
        print '---------------------done--------------------'
    #處理單個掃描任務記錄進度 
開發者ID:vulscanteam,項目名稱:vulscan,代碼行數:15,代碼來源:function.py

示例5: exec_multi_threading

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def exec_multi_threading(size, proxys):
        pool = threadpool.ThreadPool(size)

        reqs = threadpool.makeRequests(GetFreeProxy.validUsefulProxy, proxys)
        [pool.putRequest(req) for req in reqs]
        pool.wait() 
開發者ID:V-I-C-T-O-R,項目名稱:12306,代碼行數:8,代碼來源:get_free_proxy.py

示例6: start_service

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def start_service(love):
    import threadpool
    pool = threadpool.ThreadPool(2)
    reqs = threadpool.makeRequests(super_hero, [love])
    [pool.putRequest(req) for req in reqs]
    reqs = threadpool.makeRequests(girl_of_the_night, [love])
    [pool.putRequest(req) for req in reqs]
    pool.wait() 
開發者ID:V-I-C-T-O-R,項目名稱:12306,代碼行數:10,代碼來源:fuckeverything.py

示例7: add

# 需要導入模塊: import threadpool [as 別名]
# 或者: from threadpool import makeRequests [as 別名]
def add(self, fn, args):
        import threadpool
        if type(args) == list:
            args = [(args, None)]
        elif type(args) == dict:
            args = [(None, args)]
        else:
            raise ValueError, "Unsuported args,", type(args)
        request = threadpool.makeRequests(fn, args)[0]
        self.pool.putRequest(request, block = False)
        self.pool.poll() 
開發者ID:HLIG,項目名稱:HUAWEIOCR-2019,代碼行數:13,代碼來源:thread_.py


注:本文中的threadpool.makeRequests方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。