示例#1
0
def shutdown(poolclass, n):
	e = Executor(poolclass, StreamMap(lambda x: x * x), pool_size=2)
	e.submit_jobs(*range(n))
	e.shutdown()
	print e.result >> list
	assert e.input_feeder_thread.is_alive() == False
	assert e.result_tracker_thread.is_alive() == False
	assert e.failure_tracker_thread.is_alive() == False
示例#2
0
def cancel(poolclass, n):
	e = Executor(poolclass, StreamMap(lambda x: x * x), pool_size=2)
	t1 = threading.Thread(target=lambda: e.submit_jobs(*range(n // 2)))
	t2 = threading.Thread(target=lambda: e.submit_jobs(*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
示例#3
0
def submit(poolclass, n):
	e = Executor(poolclass, StreamMap(lambda x: x * x), pool_size=3)
	e.submit_jobs(*range(n))
	e.close()
	assert sum(e.result) == result[n]