Feature flags from Toggley for Python servers. The client downloads your environment's config, keeps it current in a background thread, and evaluates flags in your process. No network call per check, no dependencies, and user data never leaves your server.
pip install toggleyPython 3.10+.
import os
import toggley
client = toggley.Client(server_key=os.environ["TOGGLEY_SERVER_KEY"])
client.wait_for_initialization(timeout=5)
context = {"key": str(user.id), "email": user.email, "plan": user.plan}
if client.bool_variation("new-checkout", context, False):
...
theme = client.string_variation("theme", context, "light")Create one client per process and reuse it. Getters never raise: on any problem you get your default, and the *_variation_detail versions say why (reason["kind"] == "ERROR", reason["errorKind"]).
| Method | |
|---|---|
bool_variation, string_variation, number_variation, json_variation, variation |
the value |
..._detail |
{value, variation, reason, assignment, flagVersion} |
all_flags(context) |
{flag_key: value} |
flush(), close(), with toggley.Client(...) as client: |
Options: base_url (default https://my.toggleyapp.com), poll_interval (30s), timeout (5s), bootstrap (config dict or JSON file path), offline, events (send evaluation counts every minute; counts only), on_error.
If Toggley can't be reached the client keeps serving the last config it received and retries with backoff. A rejected key stops polling.
Forking servers (gunicorn, uWSGI) are handled: the polling thread restarts in each worker. Counts are sent at exit.