🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

quickpool

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quickpool

Use ProcessPoolExecutor and ThreadPoolExecutor from concurrent.futures with a progress bar and less boilerplate.

2.0.0
Maintainers
1

quickpool

Use ProcessPoolExecutor and ThreadPoolExecutor from concurrent.futures with a progress bar and less boilerplate.

Installation

Install with:

pip install quickpool

Usage

>>> import random
>>> import time
>>> import quickpool
>>> def naptime(base_duration: float, multiplier: float, return_val: int)->int:
...   time.sleep(base_duration * multiplier)
...   return return_val
...
>>> def demo():
...   iterations = 25
...   pool = quickpool.ThreadPool(
...   functions = [naptime] * iterations,
...   args_list = [(random.random() * 5, random.random()) for _ in range(iterations)],
...   kwargs_list = [{"return_val": i} for i in range(iterations)])
...   results = pool.execute()
...   print(results)
...
>>> demo()
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 3s
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts