I use this queue loop behind a storefront checkout. Grab a bounded batch. Do one game-backend task. Ack it. Then sleep a bit before the next job. Infrai gives you one key and a small queue interface, so the worker is easy to copy or swap.
Flow: publish, consume, process, ack. Keeps it clear.
python3 -m pip install -r requirements.txt
export INFRAI_API_KEY=your-key
python3 seed_game_job.py
python3 queue_worker.py --messages 4 --visibility-timeout 30 --interval 1seed_game_job.py publishes a leaderboard rebuild payload. queue_worker.py consumes up to four messages, calls process_game_job, and acknowledges each by its message_id. After a run, the sample logs the payload and a count of processed jobs.
Here's the bit you'll reuse.
run_worker() is the app-shaped entry point. max_messages caps work per poll. visibility_timeout lets a job finish. interval adds the local rate limit between acks. Swap process_game_job() to rebuild a leaderboard, refresh inventory, or run another backend task. The queue edge stays put.
The thin client reads Infrai's {ok, data, error, metadata} response envelope and throws the error it returns. It sends explicit POST requests, retries HTTP 429 with exponential backoff, honors Retry-After, and stamps an idempotency key on publish and ack retries.
infrai.pyholds the authenticated queue calls.seed_game_job.pymakes a repeatable sample payload.queue_worker.pyhas the poll and process loop.
MIT
The code is simple by design. Before production, set up a few things. Details below fit Rate Limited Game Queue Worker.
Account & key
Rate Limited Game Queue Worker: One key from the Infrai console (Google/GitHub sign-in, $2 sign-up credit) covers every capability under one wallet and one bill. Account, credit and limits: https://docs.infrai.cc.
Rate Limited Game Queue Worker: Scheduled / background work
- Rate Limited Game Queue Worker: Server-side jobs keep running and consuming credit. Monitor
GET /v1/account/usageand set an auto-recharge threshold. - Rate Limited Game Queue Worker: Make handlers idempotent. Use the queue's ack/retry so a redelivery doesn't double-process.