Skip to main content

A simple threadpool utility

Project description

SimpleThreads - A simple thread pool utility
============
A simple thread pool for python 2.x+<br/>
If you are missing ThreadPoolExecutor in python 2.x, here is a simple thread pool manager.

Installation:
============

pip install simplethreads

Usage:
============

- Define tasks

def task_a():
# do something
pass

def task_b(a,b,c):
# do something more
pass

- Create a thread pool to schedule your tasks.

from simplethreads.ThreadPool import ThreadPool

# Create thread pool with nums threads
pool = ThreadPool(nums)

# Add a task into pool
pool.process(task_a)

# Pass arguments to task
pool.process(task_b,1,2,3)

# Cleanup before exit
# default value of block=True
# set to false if you dont want to wait till all the tasks are processed
# (Tasks will be processed in background though!)
pool.shutdown(block=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SimpleThreads-1.2.tar.gz (2.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page