Python & FastAPI
FastAPI, async, packaging and the ORM - building and shipping Python services without the event loop or the dependency tree fighting you.
Sub-topics
FastAPI
17Routing, dependencies, validation and running it in production.
Async & Concurrency
6The event loop, blocking calls, Celery and background work.
Packaging & Environments
5pip, poetry, uv, virtualenvs and ModuleNotFoundError.
Databases & ORM
5SQLAlchemy sessions, connection pools and query patterns.
Testing
2pytest, fixtures, async tests and flaky suites.
33 articles · showing 1-9 (page 1 of 4)
M-Pesa Reconciliation That Scales: From Paybill Statement to Trial Balance
Stop reconciling in spreadsheets. A three-way match between the Safaricom statement, your callback events and a double-entry ledger, with named break categories and a daily close job in Python and SQL.
M-Pesa "Invalid BusinessShortCode": The Python requests Bug Behind It
Daraja error 400.002.02 blames your shortcode, but the real cause is usually data=payload instead of json=payload in Python requests. Here is how to prove it.
MySQL server has gone away: four unrelated causes, one message
Errors 2006 and 2013 are a shrug, not a diagnosis. Idle timeouts, packet size, read timeouts and a crashed server all produce them, and each needs a completely different fix.
FATAL: sorry, too many clients already - and why raising max_connections is wrong
Every Postgres connection is a separate OS process, so raising max_connections trades a clear error for an OOM. Here is the connection maths and the PgBouncer fix.
Your Redis Cache Is Serving Yesterday's Data: Fixing Invalidation Properly
Stale cache incidents have no error message, only a DEL that returns 0. Here is why Redis invalidation breaks, the structural fix, and how to prove it worked.
Celery's unresolved worker memory leak: what actually helps when nothing fixes it
Celery's parent process RAM climbs for days with no confirmed cause upstream. Here is what the open issue really says, and the mitigations that hold your server up meanwhile.
The asyncio SSL Memory Leak Nobody Warns You About, and How to Work Around It
Long-running asyncio TLS services can leak memory in the SSL transport, growing RSS until the OOM killer strikes. Here is how to confirm it, mitigate it, and track the real fix.
Daraja 404.001.03: Cache the Access Token, Don't Mint a New One
M-Pesa Daraja tokens live about an hour. Fetching one per request gets you throttled; caching forever gets you 404.001.03. The proactive refresh pattern Safaricom never documents.
FastAPI 422 Unprocessable Entity: Read the Error Body Instead of Guessing
FastAPI already tells you exactly which field is wrong in the 422 response body. Stop relaxing validation. Read detail[].loc, and fix the three payload mistakes that cause almost every 422.