def shutdown(poolclass, n): e = Executor(poolclass, map(lambda x: x*x), poolsize=2) e.submit(*range(n)) e.shutdown() print e.result >> list assert e.inputfeeder_thread.is_alive() == False assert e.resulttracker_thread.is_alive() == False assert e.failuretracker_thread.is_alive() == False
def cancel(poolclass, n): e = Executor(poolclass, map(lambda x: x*x), poolsize=2) t1 = threading.Thread(target=lambda: e.submit(*range(n//2))) t2 = threading.Thread(target=lambda: e.submit(*range(n//2))) t1.start() t2.start() cancelled = e.cancel(*range(0, n, 2)) t1.join() t2.join() e.close() completed = len(e.result >> list) print completed, cancelled assert completed + cancelled == n
def shutdown(poolclass, n): e = Executor(poolclass, map(lambda x: x * x), poolsize=2) e.submit(*range(n)) e.shutdown() print e.result >> list assert e.inputfeeder_thread.is_alive() == False assert e.resulttracker_thread.is_alive() == False assert e.failuretracker_thread.is_alive() == False
def cancel(poolclass, n): e = Executor(poolclass, map(lambda x: x * x), poolsize=2) t1 = threading.Thread(target=lambda: e.submit(*range(n // 2))) t2 = threading.Thread(target=lambda: e.submit(*range(n // 2))) t1.start() t2.start() cancelled = e.cancel(*range(0, n, 2)) t1.join() t2.join() e.close() completed = len(e.result >> list) print completed, cancelled assert completed + cancelled == n
def submit(poolclass, n): e = Executor(poolclass, map(lambda x: x*x), poolsize=3) e.submit(*range(n)) e.close() assert sum(e.result) == result[n]
def submit(poolclass, n): e = Executor(poolclass, map(lambda x: x * x), poolsize=3) e.submit(*range(n)) e.close() assert sum(e.result) == result[n]