gradio
267ba1e4 - Max parallel threads (#1460)

Commit
3 years ago
Max parallel threads (#1460) * Set max parallel threads to 100. I could not find a better solution than monkey-patching `anyio.to_thread.run_sync` to use a custom `CapacityLimiter`. I did try to obtain the predictions inside a context handler instead: ``` async with self.limiter: predictions = await run_in_threadpool(block_fn.fn, *processed_input) ``` However, that approach didn't seem to work. * Make max parallel threads configurable. `max_threads` can now be used in `launch` to specify the desired number of parallel threads supported. * Fix import order. * Update gradio/blocks.py * Replace `run_in_threadpool` with `run_sync`. We create the capacity limiter on launch, and invoke `anyio.to_thread.run_sync` directly instead of going through `run_in_threadpool`. This allows for some code simplification: we no longer need to patch `anyio.to_thread.run_sync`. * max_parallel_threads - resolve conflicts * max_parallel_threads - solve error * max_parallel_threads - solve async error Co-authored-by: Pedro Cuenca <pedro@latenitesoft.com>
Author
Parents
Loading