摘要: ## 线程回调 ```python 1,创建一个线程对象,线程对象的执行任务函数:task,task的参数是回调函数call_back,回调函数的参数是task的执行结果. def call_back(res): print("任务结果拿到了:%s" % res) def task(callback): # global res print("run") tim... 阅读全文
posted @ 2019-06-09 18:59 Python-Man 阅读(307) 评论(0) 推荐(0) 编辑
摘要: ## GIL锁: ```python 官方解释: ''' In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple native threads from executing Python bytecodes at once. This lock is necessary mainly... 阅读全文
posted @ 2019-06-09 18:57 Python-Man 阅读(413) 评论(0) 推荐(0) 编辑
摘要: ## 守护进程 ```python def task(name=None,age=None): print("子进程为守护进程") time.sleep(5) print("守护结束",name,age) if __name__=="__main__": print("父进程开始") p=Process(target=task,kwargs={"name... 阅读全文
posted @ 2019-06-09 18:53 Python-Man 阅读(222) 评论(0) 推荐(0) 编辑