Python脚本挂起并说Timeout thread called n

2024-05-14 09:49:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我想并行运行各种命令。我正在使用线程

下面是我的程序

def run():
 DeviceList = { 
  'naa.500601': ['vmhba4:C0:T3:L0', 'vmhba4:C0:T2:L0', 'vmhba3:C0:T3:L0',
       'vmhba3:C0:T2:L0']
  'naa.50002': ['vmhba4:C0:T0:L2', 'vmhba3:C0:T0:L2']
  'naa.50002a':['vmhba4:C0:T0:L0', 'vmhba3:C0:T0:L0']
  'naa.6005': ['vmhba2:C0:T0:L1']
  'naa.60a98':['vmhba3:C0:T10:L11', 'vmhba4:C0:T12:L11', 'vmhba3:C0:T11:L11',    
     'vmhba4:C0:T13:L11', 'vmhba3:C0:T12:L11', 'vmhba3:C0:T13:L11', 
     'vmhba4:C0:T10:L11', 'vmhba4:C0:T11:L11']
   'naa.60a980': ['vmhba4:C0:T13:L43', 'vmhba3:C0:T12:L43', 'vmhba3:C0:T13:L43', 
      'vmhba4:C0:T10:L43', 'vmhba4:C0:T11:L43', 'vmhba3:C0:T10:L43',          
       'vmhba4:C0:T12:L43', 'vmhba3:C0:T11:L43']
 }
 Threads = []
 for device,paths in DeviceList.items():
  disablePathThread = threading.Thread(target = DisableStoragePath,args=(paths,))
  disablePathThread.start()
  Threads.append(disablePathThread)
 for t in Threads:
    t.join()

def DisableStoragePath(paths):
   for path in paths:   
      '''
       Execute some command
      ''' 
run() # Invoke Run method

当我运行这个程序时,它运行了一段时间,然后挂起,几分钟后,线程超时,并显示错误消息“Timeout thread Called now for pathEnableDisable.py”

如果我的字典“DeviceList”中有更多的键和值,它就会挂起 你能帮我解释一下为什么这个程序会被搁置在中间吗


Tags: 程序forpathsc0devicelistl0t0t12

热门问题