Skip to main content

reids高并发队列(高并发爬虫利器)

Project description

包安装:

pip install redis-queue-tool

使用例子:

##### 1.发布消费字符串类型任务
    from redis_queue_tool.RedisQueue import RedisPublish, RedisCustomer, init_redis_config


    # redis连接配置
    init_redis_config(host='127.0.0.1', password='', port=6379, db=8)

    for zz in range(1, 501):
        # 发布字符串任务 queue_name发布队列名称 fliter_rep=True任务自动去重(默认False)
        RedisPublish(queue_name='test1', fliter_rep=False).publish_redispy_str(str(zz))


    def print_msg_str(msg):
        print(f"msg_str:{msg}")


    # 消费字符串任务 queue_name消费队列名称 max_retry_times错误最大重试次数
    RedisCustomer(queue_name='test1', consuming_function=print_msg_str, process_num=2, threads_num=100,
                  max_retry_times=5).start_consuming_message()


##### 2.发布消费多参数类型任务
    from redis_queue_tool.RedisQueue import RedisPublish, RedisCustomer, init_redis_config

    # redis连接配置
    init_redis_config(host='127.0.0.1', password='', port=6379, db=8)

    for zz in range(1, 501):
         # 发布多参数任务
         RedisPublish(queue_name='test2').publish_redispy(c=str(zz), b=str(zz), a=str(zz))


    def print_msg_dict(a, b, c):
        print(f"msg_dict:{a},{b},{c}")


    # 消费多参数类型任务 queue_name消费队列名称 is_support_mutil_param=True消费函数支持多参数(默认False) qps每秒消费任务数
    RedisCustomer(queue_name='test2', consuming_function=print_msg_dict, process_num=2, threads_num=100,
                  max_retry_times=5, is_support_mutil_param=True, qps=50).start_consuming_message()

##### 3.批量提交任务
    from redis_queue_tool.RedisQueue import RedisPublish, init_redis_config

    # redis连接配置
    init_redis_config(host='127.0.0.1', password='', port=6379, db=8)

    result = [str(i) for i in range(1, 501)]
    # 批量提交任务 queue_name提交任务队列名称 max_push_size每次批量提交记录数(默认值50)
    RedisPublish(queue_name='test3', max_push_size=100).publish_redispy_list(result)

Project details


Release history Release notifications | RSS feed

This version

3.9

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-3.9.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redis_queue_tool-3.9-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file redis-queue-tool-3.9.tar.gz.

File metadata

  • Download URL: redis-queue-tool-3.9.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for redis-queue-tool-3.9.tar.gz
Algorithm Hash digest
SHA256 7a6d5a21ec0998baa1e2a26270232ed9c8e305513105651f1d50c18db3574466
MD5 ea782c153651ca182c9e15bc040cf30e
BLAKE2b-256 5dcfe798414427ac8b05095c698896a351914451c509ac91f9da1e22b63e1662

See more details on using hashes here.

File details

Details for the file redis_queue_tool-3.9-py3-none-any.whl.

File metadata

  • Download URL: redis_queue_tool-3.9-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for redis_queue_tool-3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8c29558306a235d7f17dc59fe3b9747d0a696477fd1b8e61144457d89fe8a6f8
MD5 fed52673effd6c062ea10ee27a93a708
BLAKE2b-256 ec773a3fac430131783fbf8d22d64028ba55b690e315140b7d709a1b9d7113dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page