当前位置: 首页 > news >正文

广州市广园路建设公司网站中国八大设计院指的是哪些

广州市广园路建设公司网站,中国八大设计院指的是哪些,上海wordpress网站建设,wordpress怎么添加主页并发编程-进程 进程创建启动 python提供了multiprocessing模块来支持多进程 multiprocessing.Process(targettask, args(arg,))用于创建进程 Process类相关方法 start() 启动进程join() 等待进程结束 启动子线程 【注意】线程启动代码块要放在__name__ __main__下 方式…并发编程-进程 进程创建启动 python提供了multiprocessing模块来支持多进程 multiprocessing.Process(targettask, args(arg,))用于创建进程 Process类相关方法 start() 启动进程join() 等待进程结束 启动子线程 【注意】线程启动代码块要放在__name__ __main__下 方式一 import multiprocessing import timedef task(name: str, count: int):print(f{name} - step 1\n, end)result 0for i in range(count):result i 1time.sleep(5)print(f{name}- end with {result})def start_process1():name p1count 100process multiprocessing.Process(targettask, args(name, count))process.start()process.join()print(main process over)if __name__ __main__:start_process1()运行结果 PS F:\Code\python_code\high_python\python_advance\multiprocesses python .\multiprocesses_demo.py p1 - step 1 p1- end with 5050 main process over查看进程信息一条进程是python用来做资源监控的所以有两条。 PS F:\Code\python_code\high_python tasklist.exe|findstr python python.exe 19588 Console 2 11,436 K python.exe 14300 Console 2 11,644 K方式二 import multiprocessing import timedef task(name: str, count: int):print(f{name} - step 1\n, end)result 0for i in range(count):result i 1time.sleep(5)print(f{name}- end with {result})def statr_process2():args_list [(a, 100), (b, 99), (c, 98)]processes [multiprocessing.Process(targettask, args(name, count)) for name, count in args_list]for p in processes:p.start()for p in processes:p.join()# 创建进程 if __name__ __main__:statr_process2()运行结果 PS F:\Code\python_code\high_python\python_advance\multiprocesses python .\multiprocesses_demo.py a - step 1 b - step 1 c - step 1 a- end with 5050 b- end with 4950 c- end with 4851检查进程信息 PS F:\Code\python_code\high_python tasklist.exe|findstr python python.exe 15016 Console 2 11,576 K python.exe 13820 Console 2 11,520 K python.exe 3676 Console 2 11,632 K python.exe 3080 Console 2 11,624 K进程池 进程的创建和销毁比起线程更加耗费资源频繁的创建和销毁线程对系统的性能影响更大进程池是python提供的便于进程管理和提高性能的工具 使用进程池 python提供了两个类concurrent.futures.ProcessPoolExecutor和Future ProcessPoolExecutor相关方法 submit() # 启动一个线程任务返回一个Future类的对象map() # 不相同任务不同参数启动多进程返回可迭代对象包含任务执行结果shutdown() # 停止进程 Future相关方法 result() # 任务执行结果exception() # 执行出现的异常 下载图片案例 from concurrent.futures import ProcessPoolExecutor from urllib.request import urlopen, Request import osheaders {User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36,content-type: Content-Type: image/jpeg } def download_img(url: str):site_url Request(url, headersheaders)with urlopen(site_url) as web_file:img_data web_file.read()if not img_data:raise Exception(fError: can not load the image from {url})file_name os.path.basename(url)with open(file_name, wb) as f:f.write(img_data)return Download image successfully, {}.format(url)urls [https://img0.bdstatic.com/static/searchresult/img/baseimg3_4f26a23.png,# ... ]def main():with ProcessPoolExecutor() as ececutor:results ececutor.map(download_img, urls)for r in results:print(r) if __name__ __main__:main()运行结果 PS F:\Code\python_code\high_python\python_advance\multiprocesses python .\multiprocess_pool.py Download image successfully, https://img0.bdstatic.com/static/searchresult/img/baseimg3_4f26a23.png
http://www.w-s-a.com/news/414186/

相关文章:

  • 响应式网站建设服务商wordpress 非小工具形式 微博秀
  • 网站安全检测漏洞扫描风险等级分布建设一个网站步骤
  • 摄影网站的意义开发企业小程序公司
  • 龙岩网站设计招聘信息网上免费logo设计
  • 高端定制网站开发建站教程详解网站共享备案可以申请支付接口
  • 做房产网站接不到电话企业推广宣传方式
  • 网站建设费用不用摊销下一页p30
  • 北京 工业网站建设公司国外服务器公司有哪些
  • 怎样局域网站建设盈利网站
  • 公司做网站广告语济南建网站价格消费品展
  • 建德网站网站建设规划设计书
  • 谷歌网站流量分析wordpress置顶浮标
  • 江苏新宁建设集团网站网络规划设计师2023论文
  • 合作建站协议python wordpress采集器
  • 集团网站网页模板网站建设图片大全
  • 举报非法网站要求做笔录wordpress怎么插视频
  • 网站服务器防护如何搭建网站平台
  • 设计师接私活的网站如何做网站的搜索栏
  • ps做图下载网站网站子目录设计
  • 厦门网站制作策划高中生做网站网页
  • 高端品牌网站建设在哪济南兴田德润优惠吗专业定制网站开发公司
  • 怎么做网站卖东西汽车网站排行榜前十名
  • 网站关键字没有排名只有单页面的网站怎么做seo
  • 网站流量盈利模式宝塔没有域名直接做网站怎么弄
  • 淡蓝色网站qq推广中心
  • 设计网站价格餐饮吸引客流的活动方案
  • 手机网站建设电话百度搜索量
  • 条件查询 php网站源码中国白云手机网站建设
  • 网上注册公司流程及材料班级优化大师免费下载电脑版
  • 应用网站如何做营销型网站的重要特点