Skip to main content

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.2.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

thread_worker-0.1.2-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

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