An open API service indexing awesome lists of open source software.

https://github.com/null-none/threadpools

This is a simple thread pool for python (using queue module).
https://github.com/null-none/threadpools

python python3 queue thread

Last synced: 7 months ago
JSON representation

This is a simple thread pool for python (using queue module).

Awesome Lists containing this project

README

          

# threadpools
This is a simple thread pool for python (using queue module).

#### Install
```bash
pip install threadpools
```

#### Example

```python
from threadpools import ThreadPools
import requests

urls = ["https://jsonplaceholder.typicode.com/todos/{}".format(i) for i in range(30)]
pool = ThreadPools(30)
r = requests.session()
def get(url):
resp = r.get(url)
return resp.json()
pool.map(get, urls)
pool.destroy()

pool = ThreadPools(30)
r = requests.session()
def get():
resp = r.get("https://jsonplaceholder.typicode.com/todos/1")
return resp.json()
pool.add_task(get)
pool.destroy()
```