Skip to content

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

License

Notifications You must be signed in to change notification settings

null-none/threadpools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

threadpools

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

Install

pip install threadpools

Example

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()

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages