Skip to main content

飞快的请求库

Project description

JFSmallThread

简易版并发请求库:支持http协议高并发发送,比 aiohttp和requests 更快。 设置tps,控制函数发送速度, 提高执行效率

N|Solid

Build Status

Installation

pip install JFSmallThread

设置tps
tps_pool = TpsThreadPoolExecutor(tps=20)
    for i in range(100):
        # tps_pool.submit(f1, i)
        tps_pool.submit(test_by_nb_http_client)
    tps_pool.shutdown()
    
不设置
http_pool = ObjectPool(object_type=HttpOperator, object_pool_size=50,
                       object_init_kwargs=dict(host='xxxx', port=xxx),
                       max_idle_seconds=30)

thread_pool = BoundedThreadPoolExecutor(50)


def test_http_client():
    """
    type: typing.Union[HttpOperator,HTTPConnection]
    http对象池的请求速度暴击requests的session和直接requests.get
    """
    with http_pool.get() as conn:
        r1 = conn.speed_request()
        print(r1.text)

License

MIT

Free Software, Hell Yeah!

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

JFSmallThread-1.0.0.tar.gz (7.8 kB view hashes)

Uploaded Source

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