您的位置:首页 > 其它

Threading Module源码概述(一)

2016-01-05 21:36 281 查看
  Python的Threading模块是建立在thread module基础上的一个模块,在threading模块中,暴露着许多thread模块的属性。比如threading._get_ident实际上就是thread.get_ident.

def start(self):
try:        #调用_start_new_thread创建子线程
_start_new_thread(self.__bootstrap, ())

def __bootstrap(self):
try:
self.__bootstrap_inner()

def __bootstrap_inner(self):
try:
self._set_ident()   #获得线程id
self.__started.set()
with _active_limbo_lock:
_active[self.__ident] = self   #将线程id保存到_active的dict
del _limbo[self]   #移除之前limbo字典中的线程


第二步
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: