agronholm / pythonfutures

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

ThreadPoolExecutor should fail when max_worker is 0 #55

Closed leplatrem closed 7 years ago

leplatrem commented 8 years ago

I noticed a difference when instantiated the executor with ThreadPoolExecutor(max_workers=0). The backport does not raise, whereas the 3.5 raises a ValueError:

  File "/opt/python/3.5.0/lib/python3.5/concurrent/futures/thread.py", line 96, in __init__
    raise ValueError("max_workers must be greater than 0")

ValueError: max_workers must be greater than 0
agronholm commented 8 years ago

The backport is a backport of Python 3.2's ThreadPoolExecutor. That said, I guess this is trivial enough to incorporate in the backport.

leplatrem commented 8 years ago

You're right, there is no error in python 3.2.

I just wanted to let you know because I came into it, but I don't think it is crucial ;)

cutewalker commented 7 years ago

well, why does this backport keep API of py32 which is too old for production use.
Both max_workers is 0 and None ( #54 ) will silently lead to an executor with no worker, that is really too bad

agronholm commented 7 years ago

The changes made in the newer versions of concurrent.futures require Python core changes to work. That's why I haven't backported any newer versions. For reliable process pools, you must upgrade to Python 3.x. As for this particular change, I'll make it happen this week when I have the time.

agronholm commented 7 years ago

Fixed in 09138538e446dbe7664bfab5b29fd2d51e625d4d.

cutewalker commented 7 years ago

Aha, thanks very much for such a quick response, and sorry for the late regards.