thread work
Project description
thread_work
多线程队列消费work 含有优先级的work 有限流的work
work
Worker
普通多线程work
WorkerPrior
优先消费队列work
LimitWork
限流work
使用
举例 限流的work
默认一个线程1s发一条 创建三个线程1s发三条
from thread_worker import LimitWork
import requests
def create_work():
work = LimitWork(consumer_count=3)
for i in range(100):
work.put({"iid": i})
return work
def consumer(data):
iid = data["iid"]
url = "http://127.0.0.1:8088/{0}".format(iid)
resp = requests.get(url=url).content
print(resp)
def run():
work = create_work()
work.run(consumer)
print("end")
run()
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
thread_worker-0.1.6.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for thread_worker-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20cc94477950e3c299ca9756d30eb4a37d129230e67353ee696f3c6d1eb682ed |
|
MD5 | 0fd982f387584ee2a94538d690036768 |
|
BLAKE2b-256 | 180811d0f903804322d2afe4ef0c856867749d38d51d01aa45c3b2167240b9db |