Skip to content

Python library distributing tasks among processes and threads.

License

Notifications You must be signed in to change notification settings

michalmonday/PT_Pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What PT_Pool?

It's a combined process+threading pool. (having only "apply_async" method for now)

ThreadPoolExecutor on its own doesn't utilize more than one CPU core.
ProcessPoolExecutor on its own is not suitable to provide concurrency (e.g. slows down the system when large number of processes are created, and doesn't allow to create more than around 1000 processes on my system).

Installation

python3.7 -m pip install PT_Pool

Usage

from PT_Pool import PT_Pool
import time

def f(x):
    time.sleep(1)
    return x*x

def on_result(res):
    print(res)

pt_pool = PT_Pool(threads_limit = 100)

pt_pool.apply_async(f, range(10), on_result=on_result)

time.sleep(2)
input('Press enter to exit...')

About

Python library distributing tasks among processes and threads.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages