本文整理汇总了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.")