Pycon Tanzania 2026

Offline First: Building Python Tools for Low-Connectivity Environments

PyCon Long Talk, 30 min Python Core & Tooling Intermediate
Thursday 26 November 14:00 to 16:00 Main Hall, State University Of Zanzibar

Most Python apps assume fast, always-on internet. In many parts of Eastern Africa and beyond, that assumption breaks: connections drop, data is expensive, and latency is high. This talk shows how to build Python tools that keep working offline and sync reliably when the network returns. We’ll cover local-first storage with SQLite, retries with backoff, idempotent sync, and shrinking payloads. You’ll leave with patterns and code you can apply to your next project.

Networks fail in predictable ways: timeouts, dropped connections mid-upload, and duplicate requests after retries. Code that ignores this loses data or charges users twice. This talk walks through a small Python field-data tool and makes it resilient step by step.

Outline (30 min)

The problem (4 min): what actually goes wrong on unreliable networks, and why the defaults hurt (requests has no timeout unless you set one).
Fail well (6 min): explicit timeouts, retries with exponential backoff and jitter using urllib3.Retry or tenacity, and knowing which errors are safe to retry.
Local-first storage (7 min): writing to SQLite first, so the app works offline, and using an outbox table to queue changes for later sync.
Safe sync (7 min): idempotency keys so retried requests don’t create duplicates, resumable batch uploads, and simple conflict handling (last-write-wins vs. version numbers).
Use less data (3 min): gzip compression, conditional requests with ETags, sending only changed fields, and keeping dependencies light.
Wrap-up and Q&A (3 min)

Takeaways

A checklist for making any Python HTTP client resilient
The outbox pattern with SQLite for offline-first apps
How to design sync that’s safe to retry

Audience: intermediate. Attendees should be comfortable with Python and basic HTTP APIs.
Code: a demo repo with a network-failure simulator, so attendees can reproduce every scenario.