reids高并发队列(高并发爬虫利器)
Project description
包安装:
pip install redis-queue-tool
使用例子:
from redis_queue_tool import RedisQueue from redis_queue_tool.RedisQueue import RedisPublish, RedisCustomer # redis连接配置 RedisQueue.redis_host = '127.0.0.1' RedisQueue.redis_password = '' RedisQueue.redis_port = 6379 RedisQueue.redis_db = 0 quenen_name = 'test1' # 初始化发布队列 fliter_rep=True任务自动去重 redis_pub = RedisPublish(queue_name=quenen_name, fliter_rep=True) result = [str(i) for i in range(1, 101)] for zz in result: redis_pub.publish_redispy(a=zz, b=zz, c=zz) # 多线程单条记录写入 redis_pub.publish_redispy_list(result) # 单线程批量写入1 for zz in result: redis_pub.publish_redispy_mutil(zz) # 单线程批量写入2 def print_msg(msg): print(json.loads(msg)) # 多线程消费 redis_customer = RedisCustomer(quenen_name, consuming_function=print_msg, threads_num=100,max_retry_times=5) print(redis_customer.threads_num) redis_customer.start_consuming_message()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis-queue-tool-1.9.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for redis_queue_tool-1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e977df7252c3f8cba463a020961475a99c9a76b23cc686aaadcdee687706419 |
|
MD5 | 188f04093427a7a7dc1c866194d8ea2c |
|
BLAKE2b-256 | 4190463b45e3eded94e72c3fed6a5a36c1817f6f5970a162fe30516ce79595d9 |