anyio icon indicating copy to clipboard operation
anyio copied to clipboard

What is the size of the threading default limiter?

Open prprprus opened this issue 3 years ago • 2 comments

Hi all.

When I read the documentation description of anyio.to_thread.run_sync function, it doesn't explicitly state how much default limiter is.

So, I went to the source code and found that limiter = CapacityLimiter(40).

Question:

  • Is the size of threading default limiter 40?
  • If not, what is the correct threading default limiter?

I hope some kind-hearted people can answer my doubts, thank you very much!

prprprus avatar Jun 23 '22 09:06 prprprus

Is the size of threading default limiter 40?

Yes, this is the default thread limiter. It's the same size as in trio.

This seems like a glaring omission in the documentation. I'll keep this issue open until the default limiter has been properly documented.

agronholm avatar Jun 26 '22 14:06 agronholm

Thanks to @agronholm for the reply and thanks to the extraordinary anyio.

In my case, the background information is that I am building a RESTful application using FastAPI and I need to evaluate the default thread pool size so that I can better schedule the server resources. As you know, FastAPI's thread pool is dependent on Starlette, and Starlette's thread pool is dependent on anyio(after version 0.15.0).

I think it would be better to specify the default size of the thread pool in the documentation if possible, it will be more friendly.

prprprus avatar Jun 28 '22 10:06 prprprus