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


Python ThreadPool.get_progress方法代码示例

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


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

示例1: main

# 需要导入模块: from threadpool import ThreadPool [as 别名]
# 或者: from threadpool.ThreadPool import get_progress [as 别名]
def main():
    start_time = time.time()
    parser = add_parser()
    args = parser.parse_args()
    app_dir = args.path + "\\" + args.app_dir
    global encoding
    encoding = args.encoding
    #line feed
    line_feed = "\n"
    # use console to show information
    global console
    console = Console()

    console.show("Target Path:      " + args.path)
    console.show("Webapp Directory: " + app_dir)
    console.show("Testing Website:  " + args.website)
    console.show("Output File:      " + args.output)

    # start fetching
    console.show("Start fetching url and its parameters in " + args.path)

    global url_data
    url_data = UrlData()
    get_url_list(args.path, app_dir, args.website)
    url_amount = url_data.len()

    #fetch complete
    console.show("Fetched " + str(url_amount) + " url(s).")
    if args.get_status != 1 or args.website == "":
        url_data.export(args.output)
        #exit
        sys.exit()

    console.show("Start testing url status with " \
            + str(args.thread_num) + " thread(s).")
    #init thread pool
    pool = ThreadPool(args.thread_num)
    
    for url in url_data.get_urls():
        pool.add_task(url_request, url)
        console.show_progress(pool.get_progress(), url_amount)
    
    while pool.get_progress() != url_amount:
        console.show_progress(pool.get_progress(), url_amount)
    

    #pool.destroy()
    finish_time = time.time()
    elapsed_time = int(finish_time - start_time)
    #export
    url_data.export(args.output)
    console.show("Task finished in " + str(elapsed_time) + " seconds.")
开发者ID:CyL0NG,项目名称:FetchUris,代码行数:54,代码来源:urlfetcher.py


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