Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/isayme/threadpool.py

A simple threadpool written in Python
https://github.com/isayme/threadpool.py

Last synced: 12 days ago
JSON representation

A simple threadpool written in Python

Awesome Lists containing this project

README

        

threadpool.py
=============

A simple threadpool written in Python

How to use ?
============

from threadpool import ThreadPool

import time
import random

from threading import Lock

lock = Lock()

def test_func(ntime):
time.sleep(ntime)
lock.acquire()
print('sleep {} seconds!'.format(ntime))
lock.release()

tp = ThreadPool()

tasks = (random.randrange(1, 10) for i in xrange(5))

for i in tasks:
tp.add_task(test_func, i)

tp.stop()

Contact
=======

email: [email protected]