2222
2323
2424class Config (object ):
25+
2526 def __init__ (self ,
2627 base_uri = 'https://app.launchdarkly.com' ,
2728 events_uri = 'https://events.launchdarkly.com' ,
@@ -79,6 +80,7 @@ def default(cls):
7980
8081
8182class InMemoryFeatureStore (FeatureStore ):
83+
8284 def __init__ (self ):
8385 self ._lock = ReadWriteLock ()
8486 self ._initialized = False
@@ -142,6 +144,7 @@ def initialized(self):
142144
143145
144146class LDClient (object ):
147+
145148 def __init__ (self , api_key , config = None ):
146149 check_uwsgi ()
147150 self ._api_key = api_key
@@ -152,15 +155,17 @@ def __init__(self, api_key, config=None):
152155 self ._offline = False
153156 self ._lock = Lock ()
154157
155- self ._store = config .feature_store_class ()
158+ self ._store = self . _config .feature_store_class ()
156159 """ :type: FeatureStore """
157160
158- self ._feature_requester = config .feature_requester_class (api_key , config )
161+ self ._feature_requester = self ._config .feature_requester_class (
162+ api_key , self ._config )
159163 """ :type: FeatureRequester """
160164
161165 self ._stream_processor = None
162166 if self ._config .stream :
163- self ._stream_processor = config .stream_processor_class (api_key , config , self ._store )
167+ self ._stream_processor = self ._config .stream_processor_class (
168+ api_key , self ._config , self ._store )
164169 self ._stream_processor .start ()
165170
166171 @property
@@ -170,7 +175,8 @@ def api_key(self):
170175 def _check_consumer (self ):
171176 with self ._lock :
172177 if not self ._consumer or not self ._consumer .is_alive ():
173- self ._consumer = self ._config .consumer_class (self ._queue , self ._api_key , self ._config )
178+ self ._consumer = self ._config .consumer_class (
179+ self ._queue , self ._api_key , self ._config )
174180 self ._consumer .start ()
175181
176182 def _stop_consumers (self ):
@@ -190,7 +196,8 @@ def _send(self, event):
190196 self ._queue .put (event )
191197
192198 def track (self , event_name , user , data = None ):
193- self ._send ({'kind' : 'custom' , 'key' : event_name , 'user' : user , 'data' : data })
199+ self ._send ({'kind' : 'custom' , 'key' : event_name ,
200+ 'user' : user , 'data' : data })
194201
195202 def identify (self , user ):
196203 self ._send ({'kind' : 'identify' , 'key' : user ['key' ], 'user' : user })
@@ -229,7 +236,8 @@ def cb(feature):
229236 val = _evaluate (feature , user )
230237 if val is None :
231238 val = default
232- self ._send ({'kind' : 'feature' , 'key' : key , 'user' : user , 'value' : val })
239+ self ._send ({'kind' : 'feature' , 'key' : key ,
240+ 'user' : user , 'value' : val })
233241 return val
234242
235243 if self ._config .stream and self ._store .initialized :
@@ -239,7 +247,8 @@ def cb(feature):
239247 try :
240248 return self ._feature_requester .get (key , cb )
241249 except Exception :
242- log .exception ('Unhandled exception. Returning default value for flag.' )
250+ log .exception (
251+ 'Unhandled exception. Returning default value for flag.' )
243252 return cb (None )
244253
245- __all__ = ['LDClient' , 'Config' ]
254+ __all__ = ['LDClient' , 'Config' ]
0 commit comments