摘要: import selectorsimport socketsel = selectors.DefaultSelector()def accept(sock, mask): conn, addr = sock.accept() # Should be ready print('accepted', c 阅读全文
posted @ 2018-11-19 20:43 rongye 阅读(151) 评论(0) 推荐(0)
摘要: import selectimport socketimport queueserver = socket.socket()server.bind(('localhost',9000))server.listen(1000)server.setblocking(False) #不阻塞msg_dic 阅读全文
posted @ 2018-11-19 20:13 rongye 阅读(235) 评论(0) 推荐(0)
摘要: import sysimport socketimport timeimport geventfrom gevent import socket, monkeymonkey.patch_all()def server(port): s = socket.socket() s.bind(('0.0.0 阅读全文
posted @ 2018-11-19 16:04 rongye 阅读(269) 评论(0) 推荐(0)
摘要: GET: https://www.python.org/50114 bytes received from https://www.python.org/.GET: https://www.yahoo.com/505000 bytes received from https://www.yahoo. 阅读全文
posted @ 2018-11-19 15:46 rongye 阅读(394) 评论(0) 推荐(0)
摘要: Running in fooExplicit精确的 context内容 to barrunning func3 running func3 again Implicit context switch back to barExplicit context switch to foo again 阅读全文
posted @ 2018-11-19 15:32 rongye 阅读(250) 评论(0) 推荐(0)
摘要: 12563478 阅读全文
posted @ 2018-11-19 15:21 rongye 阅读(151) 评论(0) 推荐(0)
摘要: import timeimport queuedef consumer(name): print(" >starting eating baozi...") while True: new_baozi = yield print("[%s] is eating baozi %s" % (name, 阅读全文
posted @ 2018-11-19 14:58 rongye 阅读(450) 评论(0) 推荐(0)
摘要: from multiprocessing import Process, Pool,freeze_supportimport timeimport osdef Foo(i): time.sleep(2) print("in process",os.getpid()) return i + 100de 阅读全文
posted @ 2018-11-19 13:58 rongye 阅读(216) 评论(0) 推荐(0)
摘要: from multiprocessing import Process, Lockdef f(l, i): #l.acquire() print('hello world', i) #l.release()if __name__ == '__main__': lock = Lock() for nu 阅读全文
posted @ 2018-11-19 11:58 rongye 阅读(178) 评论(0) 推荐(0)
摘要: from multiprocessing import Process, Managerimport osdef f(d, l): d[os.getpid()] =os.getpid() l.append(os.getpid()) print(l)if __name__ == '__main__': 阅读全文
posted @ 2018-11-19 11:48 rongye 阅读(221) 评论(0) 推荐(0)
摘要: from multiprocessing import Process, Pipedef f(conn): conn.send([42, None, 'hello from child']) conn.send([42, None, 'hello from child3']) print("",co 阅读全文
posted @ 2018-11-19 11:42 rongye 阅读(217) 评论(0) 推荐(0)
摘要: from multiprocessing import Process, Queueimport threading#import queue# def f(q):# q.put([42, None, 'hello'])def f(qq): print("in child:",qq.qsize()) 阅读全文
posted @ 2018-11-19 11:17 rongye 阅读(139) 评论(0) 推荐(0)