Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

dronedeploy/python-client

 
 

Repository files navigation

LaunchDarkly SDK for Python

Circle CI PyPI PyPI Twitter Follow

Quick setup

  1. Install the Python SDK with pip

     pip install ldclient-py
    
  2. Configure the library with your sdk key:

     import ldclient
    
  3. Get the client:

     ldclient.set_sdk_key("your sdk key")
     client = ldclient.get()
    

Your first feature flag

  1. Create a new feature flag on your dashboard

  2. In your application code, use the feature's key to check whether the flag is on for each user:

     if client.variation("your.flag.key", {"key": "user@test.com"}, False):
         # application code to show the feature
     else:
         # the code to run if the feature is off
    

Python 2.6

Python 2.6 is supported for polling mode only and requires an extra dependency. Here's how to set it up:

  1. Use the python2.6 extra in your requirements.txt: ldclient-py[python2.6]

  2. Due to Python 2.6's lack of SNI support, LaunchDarkly's streaming flag updates are not available. Set the stream=False option in the client config to disable it. You'll still receive flag updates, but via a polling mechanism with efficient caching.

Twisted

Twisted is supported for LDD mode only. To run in Twisted/LDD mode,

  1. Use this dependency:

    ldclient-py[twisted]>=3.0.1
    
  2. Configure the client:

    feature_store = TwistedRedisFeatureStore(url='YOUR_REDIS_URL', redis_prefix="ldd-restwrapper", expiration=0)
    ldclient.config.feature_store = feature_store
    
    ldclient.config = ldclient.Config(
        use_ldd=use_ldd,
        event_consumer_class=TwistedEventConsumer,
    )
    ldclient.sdk_key = 'YOUR_SDK_KEY'
    
  3. Get the client:

    client = ldclient.get()

Learn more

Check out our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.

Testing

We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.

Contributing

See CONTRIBUTING for more information.

About LaunchDarkly

About

LaunchDarkly SDK for Python

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 100.0%