#coding:utf-8
import sys
import os
import Queue
import threading
from workerpool import WorkerPool, SimpleJob
class Manager(object):
def __init__(self):
self.threadpool = WorkerPool(5)
def stop(self):
self.threadpool.shutdown()
def runSequenceCmds(self, ip_addresses, func_list, use_root = False, queue = None):
if queue is None:
queue = Queue.Queue()
for ip in ip_addresses:
self.threadpool.put(SimpleJob(queue,
self._runSequenceCmd,
(ip, func_list, use_root),
),
)
def _runSequenceCmd(self, ip, cmd, func_list, use_root = False):
for func in func_list:
go_on, result = func(cmd)
if not go_on:
break
def main():
pass
if __name__ == '__main__':
main()