Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/isayme/threadpool.py
- Owner: isayme
- License: mit
- Created: 2014-12-26T11:24:37.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-11T13:33:18.000Z (almost 10 years ago)
- Last Synced: 2024-04-16T14:21:46.633Z (8 months ago)
- Language: Python
- Size: 148 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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]