Skip to main content

Rush

This python module is for making simple tools that rush a resource, such as an API endpoint or web UI. This runs with both Python 2.6+ or 3.0+.

This was originally created to test the throttling of authentication attempts. It is quite basic, but was enough to get good results from a Django based web app. I imagine that this is good enough to indicate if rate limiting is reasonably implemented on faster systems (more likely to come down to network?).

Example

This example attempts to connect to an API endpoint which will throttle after 10 requests:

try:
    # Python 2
    from xmlrpclib import ServerProxy, Fault
except ImportError:
    # Python 3
    from xmlrpc.client import ServerProxy, Fault

from rush import Rusher


def api_auth_tester(index, thread_count):
    """
    Rush the API with invalid authentication attempts.
    """
    # prepare the worker
    proxy = ServerProxy('https://badname:supersecretpassword@api.memset.com/v1/xmlrpc/')
    yield  # yield to indicate that the worker is ready to rush
    # rush
    try:
        proxy.server.list()
    except Fault as error:
        # yield a string indicating the result
        if error.faultCode == 4:  # bad username/pass
            yield 'attempted'
        elif error.faultCode == 12:  # throttled
            yield 'throttled'

print("API rate limiting test:")
# the API will throttle after 10 requests, so make 9 requests first, then rush two calls
rusher = Rusher(api_auth_tester, 9)
# preform the first 9 requests so the next request should set a throttling indicator
duration, results = rusher.rush_and_report()
# change the number of threads we want to make
rusher.thread_count = 2
# only one call should not be throttled
rusher.rush_and_report()

This will produce output like the following:

API rate limiting test:
9 threads completed in .747115, results:
    attempted: 9
2 threads completed in .127208, results:
    attempted: 1
    throttled: 1

Metadata

Release files for python-rush 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for python-rush 1.0.0
File Interpreter ABI Platform
python_rush-1.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / python_rush-1.0.0-py2.py3-none-any.whl

Download URL python_rush-1.0.0-py2.py3-none-any.whl
Size 6.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2e10da3f9f07256ff29c056f0f8f2f2a8b278eb6aa9f081c89aef4d334c79830
BLAKE2b-256 checksum
How to use checksums
7f14d025f3ac52a0b46ed5eb33b69ba8d1347b4d11f449eda1ceca79cd4053f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python-rush 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page