The Unleash Python Client SDK is a server-side client for the Unleash feature management platform, enabling developers to integrate and evaluate feature flags within their Python applications. It connects to an Unleash server (Enterprise or Open Source) to fetch flag configurations and evaluate them locally against an Unleash context. Currently at version 6.7.0, the library maintains an active release cadence with frequent updates and bug fixes.
pip install UnleashClientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Unleash client, connect to an Unleash server, and evaluate feature flags. It includes examples for checking simple boolean flags, using context for targeted evaluations, and retrieving feature variants. Remember to replace placeholder URLs and API tokens with your actual Unleash server details, ideally through environment variables. The `initialize_client()` method starts background synchronization, and `destroy()` gracefully shuts it down.
Instead of `client.features`, use `client.feature_definitions()` which returns a dictionary of feature flag names, types, and projects. If you relied on the internal structure of feature flag objects, you'll need to refactor your code.
Refactor custom strategy classes to remove inheritance from `Strategy` and update the `apply` method signature. The `load_provisioning()` method functionality is now handled directly within the `apply` method using the `parameters` argument. Strategies must be registered as instances, not class objects.
While still functional, it's recommended to rely on a `fallback_function` for more robust default behavior when a feature flag is not found or cannot be evaluated, especially in resilient applications. If both `default_value` and `fallback_function` are provided, the client will `OR` their results.
To prevent this, consider bootstrapping the client with a local or remote toggle configuration using a `FileCache` (or custom `BaseCache` implementation) and passing it during `UnleashClient` initialization. Alternatively, ensure your application handles the `False` state gracefully during the initial sync period.
Ensure `client.initialize_client()` and `client.destroy()` are called correctly within each worker process's lifecycle (e.g., in a `post_fork` hook for Gunicorn). Refer to the official documentation for specific guidance on running in multi-process setups to prevent issues with thread management and data consistency.