摘要: 进程池有什么用呢?我们先看个栗子: from multiprocessing import Process,Pool import os import time def func(): time.sleep(2) print("the process Id is ",os.getpid()) if 阅读全文
posted @ 2020-01-06 15:09 goldtree358 阅读(189) 评论(0) 推荐(0)
摘要: 在多进程中有一个进程锁,多进程为什么还要有锁呢,进程不是独立存在的吗,要锁干什么用能 栗子: from multiprocessing import Process,Lock def func(l,i): l.acquire() print("hello world" ,i) l.release() 阅读全文
posted @ 2020-01-06 11:15 goldtree358 阅读(335) 评论(0) 推荐(0)
摘要: 使用manager在进程之间事项共享数据. 栗子: 主进程调用manager,创建一个字典d和一个列表l,启动十个子进程,每个子进程都向d和l中放数据 from multiprocessing import Process,Managerimport osdef func(d,l): d[os.ge 阅读全文
posted @ 2020-01-06 09:59 goldtree358 阅读(368) 评论(0) 推荐(0)
摘要: 转载:http://blog.itpub.net/26442936/viewspace-2153417/ 介绍 PowerPath将多路径I/O功能、自动负载平衡和路径故障切换功能集成于一身,使存储管理更加轻松。本文总结了PowerPath常用命令的使用方法操作注意事项,为主机系统管理员对HBA/路 阅读全文
posted @ 2020-01-03 16:03 goldtree358 阅读(3184) 评论(0) 推荐(0)
摘要: pipe模块可以实现进程之间数据传递 栗子1:3个进程,一个主进程,2个子进程,三个管道,三个进程通过3个管道连接,主进程发一个信息,通过2个子进程转发,最后回到主进程输出 import multiprocessing def func(pipe_end,pipe_head): msg = pipe 阅读全文
posted @ 2020-01-03 14:15 goldtree358 阅读(462) 评论(0) 推荐(0)
摘要: 多进程 import multiprocessing import threading import time def thread_run(): print(threading.get_ident()) def run(name): time.sleep(2) print('hello', nam 阅读全文
posted @ 2020-01-02 15:30 goldtree358 阅读(554) 评论(0) 推荐(0)
摘要: Python四种逐行读取文件内容的方法 https://www.jianshu.com/p/4658e3ed1fea Python 如何将字符串转为字典 https://www.cnblogs.com/OnlyDreams/p/7850920.html 阅读全文
posted @ 2019-11-27 15:34 goldtree358 阅读(103) 评论(0) 推荐(0)
摘要: Python的paramiko模块,该模块机遇SSH用于连接远程服务器并执行相关操作 SSHClient 用于连接远程服务器并执行基本命令 基于用户名和密码连接 import paramiko # 创建SSH对象 ssh = paramiko.SSHClient() # 允许连接不在know_hos 阅读全文
posted @ 2019-11-26 13:32 goldtree358 阅读(150) 评论(0) 推荐(0)
摘要: 1简单的socket server和client,完成一次通讯 import socket server = socket.socket()#创建server实例 server.bind(("localhost",9999))#绑定server IP和Port server.listen()#监听 阅读全文
posted @ 2019-11-08 16:02 goldtree358 阅读(130) 评论(0) 推荐(0)
摘要: 1、异常基础 在编程过程中为了增加友好性,在程序出现bug时一般不会将错误信息显示给用户,而是现实一个提示的页面 语法: try: print(dfer) except NameError as e: print("报错了:",e) 2、异常种类 python中的异常种类非常多,每个异常专门用于处理 阅读全文
posted @ 2019-11-08 09:27 goldtree358 阅读(131) 评论(0) 推荐(0)