def __init__(self, isThread=1, needfinishqueue=0, deamon=True): self.isThread = isThread self.idletask = {} self.Threads = [] self.alivenum = 0 self.needfinishqueue = needfinishqueue self.running = 0 self.threads_num = 10 self.deamon = deamon self.job = None self.default_object = None if self.isThread == 1: # self.lock = Lock() #线程锁 self.lock = threading.Lock() self.q_request = Queue() #任务队列 if needfinishqueue > 0: self.q_finish = Queue() #完成队列 elif self.isThread == 0: self.lock = multiprocessing.Lock() self.q_request = multiprocessing.Queue() if self.needfinishqueue > 0: self.q_finish = multiprocessing.Queue() else: from gevent.queue import JoinableQueue as geventqueue from gevent.lock import Semaphore self.lock = Semaphore() self.q_request = geventqueue() if self.needfinishqueue > 0: self.q_finish = geventqueue()
def __init__(self,isThread=1,needfinishqueue=0,deamon=True): self.isThread=isThread self.idletask={} self.Threads=[] self.alivenum=0 self.needfinishqueue=needfinishqueue self.running = 0 self.threads_num = 10 self.deamon=deamon self.job=None self.default_object=None if self.isThread==1: # self.lock = Lock() #线程锁 self.lock=threading.Lock() self.q_request = Queue() #任务队列 if needfinishqueue>0: self.q_finish = Queue() #完成队列 elif self.isThread==0 : self.lock = multiprocessing.Lock() self.q_request=multiprocessing.Queue() if self.needfinishqueue>0: self.q_finish=multiprocessing.Queue() else: from gevent.queue import JoinableQueue as geventqueue from gevent.lock import Semaphore self.lock = Semaphore() self.q_request = geventqueue() if self.needfinishqueue > 0: self.q_finish = geventqueue()