Skip to main content

requestflow

stop getting 429 ratelimited like an amateur. intelligent http scheduling and pacing for discord.py.

pypi python stars discord.py community license


why this exists

when your bot grows, commands collide, background loops spam discord, and unmanaged asyncio.gather blasts 300 requests in 10 milliseconds.

discord hits back with HTTP 429: Global rate limit hit. your whole bot freezes for everyone. commands fail. messages get dropped.

requestflow fixes this. it sits between discord.py and the discord api, intelligently pacing your requests with gcra rate-limiting, cross-guild fairness, and priority queuing.

raw discord.py vs requestflow (real 300-channel burst test)

raw discord.py (asyncio.gather):
- requested: 300
- created: 240
- dropped/failed: 60 (20% failure rate)
- terminal: spammed dozens of "WARNING Global rate limit hit. Retrying in 0.30s"

requestflow:
- requested: 300
- created: 300 (100% success rate)
- dropped/failed: 0
- terminal: dead silent. zero 429s. zero bans.

install

pip install requestflow

quickstart (2 lines)

just attach it to your bot. every single channel.send(), message.delete(), cog, and slash command is automatically scheduled, paced, and protected.

import discord
from discord.ext import commands
from requestflow import RequestFlow

bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())

# 1. initialize requestflow
flow = RequestFlow(bot, global_rate_limit=40.0, max_concurrency=16)

@bot.event
async def setup_hook():
    # 2. start the engine
    await flow.start()

@bot.command()
async def ping(ctx):
    # automatically prioritized and paced without changing your code
    await ctx.send("pong")

bot.run("TOKEN")

or use managed priorities

want your slash commands and moderation actions to jump ahead of massive background sweeps?

from requestflow import RequestFlow, Priority

async with RequestFlow() as flow:
    # critical interaction responses jump to the front of the queue
    await flow.submit(
        interaction.response.send_message,
        "fast response",
        priority=Priority.CRITICAL,
        is_interaction=True
    )

    # background audits run smoothly without blocking users
    await flow.submit(
        guild.fetch_members,
        limit=1000,
        priority=Priority.LOW,
        guild_id=guild.id
    )

features

  • gcra rate pacing: smooths request bursts before discord gets angry (defaults to 40 req/s, 50 req/s ceiling).
  • zero 429 stampedes: eliminates the thundering herd problem when rate limits unlock.
  • cross-guild fairness: deficit round-robin ensures one spammy server never starves your other servers.
  • priority queues: critical slash commands and moderator bans bypass background syncs.
  • starvation prevention: low-priority jobs age up over time so they never get stuck forever.
  • in-flight deduplication: coalesces duplicate reads so identical queries only hit discord once.
  • clean metrics: real-time p50/p95 latency and queue stats with zero external telemetry.

live metrics

inspect what your bot is doing anytime:

print(flow.stats)
MetricsSnapshot(
  submitted=300,
  completed=300,
  failed=0,
  queue_wait_p50=5.0ms,
  exec_latency_p50=32.0ms,
  active_guilds=1,
  rate_limit_429_count=0
)

test it yourself

run the included stress test bot against your own discord server:

python stress_bot.py --token YOUR_TOKEN

in discord:

  • !burst_raw 350 — watch raw discord.py drop requests and spam 429 warnings
  • !cleanup — clear the test channels
  • !burst_flow 350 — watch requestflow create all 200 with 100% success and 0 errors
  • !stats — see real-time latency and queue percentiles

community & dev

need help, got feature ideas, or building massive bots? join us:


license

MIT

Metadata

Release files for requestflow 0.1.0

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

Source distribution (sdist)

Source distribution for requestflow 0.1.0
File Size Uploaded Provenance
requestflow-0.1.0.tar.gz 25.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for requestflow 0.1.0
File Interpreter ABI Platform
requestflow-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.4 kB

Release files / requestflow-0.1.0.tar.gz

Download URL requestflow-0.1.0.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9b3d2661ca47c7749c26e44b27a405f39c40861f944e212f2f6ac966df1e26b6
BLAKE2b-256 checksum
How to use checksums
73413087933ed0e4b187591980da1356b978bfebc25f00be75f7781ad11240b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / requestflow-0.1.0-py3-none-any.whl

Download URL requestflow-0.1.0-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7390179159df7343494b46a5099097649ae49ea181355952cd06d75eacffffc
BLAKE2b-256 checksum
How to use checksums
d697085d476cb205fc7c397a3381a10d7bf2864c64ff6bf74349cd3d424c09ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for requestflow 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files 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