agronholm / pythonfutures

Backport of the concurrent.futures package to Python 2.6 and 2.7
Other
232 stars 51 forks source link

len(Executor) return number of items in queue? #44

Closed jcpunk closed 9 years ago

jcpunk commented 9 years ago

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")
agronholm commented 9 years ago

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.