摘要: 1 from gevent import monkey,spawn;monkey.patch_all() 2 from threading import current_thread 3 import time 4 # 实现了单线程下的并发,遇到i/O就切换 5 def eat(): 6 print 阅读全文
posted @ 2018-07-17 20:21 Roc_Atlantis 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 1.定时器 指定n秒后,执行任务 1 from threading import Timer,current_thread 2 import os 3 4 5 def hello(): 6 print("%s hello, world"%os.getpid()) 7 print("%s hello, 阅读全文
posted @ 2018-07-17 14:21 Roc_Atlantis 阅读(411) 评论(0) 推荐(0) 编辑