def scan_hostlist(hostlist, threads=5):
 task = threadpool.map_async(scan_host, hostlist)
 while True:
  print counter['Total'], 'hosts done'
  task.wait(1)
  if (task.ready() or hasattr(threadpool, 'done')):
   return
 threadpool.close()
 threadpool.join()

def scan_hostlist ( hostlist , threads = 5 ) : task = threadpool . map_async ( scan_host , hostlist ) while True : print counter [ 'Total' ] , 'hosts done' task . wait ( 1 ) if ( task . ready ( ) or hasattr ( threadpool , 'done' ) ) : return threadpool . close ( ) threadpool . join ( )
iterates through hostlist and scans them arguments: hostlist -- iterable with ip addresses threads -- if specified .