コード例 #1
0
ファイル: executor.py プロジェクト: Answeror/stream.py
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
コード例 #2
0
ファイル: executor.py プロジェクト: Answeror/stream.py
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
ファイル: executor.py プロジェクト: Answeror/stream.py
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]
コード例 #6
0
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]