agronholm/pythonfutures

len(Executor) return number of items in queue?

jcpunk opened this issue · 1 comments

As a feature request, can the Executor respond to a len() request by showing the number of non-finished/canceled items in the pool?

I would like a clean pythonic way of seeing how many items remain to be executed and this seemed the way to go.

psudo-code:

    myvar = list(range(1, 30))

    pool = concurrent.futures.ThreadPoolExecutor(max_workers=2)
    results = pool.map(myfunction, myvar)

    for result in results:
        print("waiting for " + str(len(pool)) + " tasks to finish")

I don't take feature requests -- this is a backport. Please direct such requests to the CPython developers who maintain the original concurrent.futures package.