上一页 1 2 3 4 5 6 ··· 10 下一页
摘要: # 服务端必须满足至少三点: # 1. 绑定一个固定的ip和port # 2. 一直对外提供服务,稳定运行 # 3. 能够支持并发 import socketserver # 自定义类用来处理通信循环 class MyTCPhanler(socketserver.BaseRequestHandler 阅读全文
posted @ 2019-07-27 06:37 zhouhao666 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 进程: 什么是进程 from multiprocessing import Process import time def task(name): print('%s is running' %name) time.sleep(3) print('%s is done' %name) # 在wind 阅读全文
posted @ 2019-07-26 05:56 zhouhao666 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 创建完子进程后,主进程所在的这个脚本就退出了,当父进程先于子进程结束时,子进程会被init收养,成为孤儿进程,而非僵尸进程 import os import sys import time pid = os.getpid() ppid = os.getppid() print 'im father' 阅读全文
posted @ 2019-07-24 06:36 zhouhao666 阅读(222) 评论(0) 推荐(0) 编辑
摘要: from multiprocessing import Process import time def task(name): print('老太监%s活着....' %name) time.sleep(3) print('老太监%s正常死亡....' %name) if __name__ == ' 阅读全文
posted @ 2019-07-24 06:10 zhouhao666 阅读(108) 评论(0) 推荐(0) 编辑
摘要: import json import time,random from multiprocessing import Process,Lock def search(name): with open('db.json','rt',encoding='utf-8') as f: dic=json.lo 阅读全文
posted @ 2019-07-24 05:59 zhouhao666 阅读(153) 评论(0) 推荐(0) 编辑
摘要: from multiprocessing import Queue q=Queue() #如果放的个数小于put的个数就会阻塞住 q.put(['first',]) q.put({'x':2}) q.put(3) q.put(4) print(q.get()) print(q.get()) prin 阅读全文
posted @ 2019-07-23 06:56 zhouhao666 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 生产者消费者模型 import time,random from multiprocessing import Process,Queue def producer(name,food,q): for i in range(3): res='%s%s' %(food,i) time.sleep(ra 阅读全文
posted @ 2019-07-22 14:53 zhouhao666 阅读(253) 评论(0) 推荐(0) 编辑
摘要: from threading import Thread import time def task(name): print('%s is running' %name) time.sleep(2) print('%s is done' %name) if __name__ == '__main__ 阅读全文
posted @ 2019-07-22 10:31 zhouhao666 阅读(89) 评论(0) 推荐(0) 编辑
摘要: from threading import Thread import time def task(name): print('%s is running' %name) time.sleep(2) print('%s is done' %name) if __name__ == '__main__ 阅读全文
posted @ 2019-07-22 09:47 zhouhao666 阅读(144) 评论(0) 推荐(0) 编辑
摘要: from threading import Thread,Lock import time n=100 def task(): global n temp=n time.sleep(0.1) n=temp-1 if __name__ == '__main__': t_l=[] for i in ra 阅读全文
posted @ 2019-07-22 09:21 zhouhao666 阅读(76) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 10 下一页