2222
2323
2424class Config (object ):
25+
2526 def __init__ (self ,
2627 base_uri = 'https://app.launchdarkly.com' ,
2728 connect_timeout = 2 ,
@@ -77,6 +78,7 @@ def default(cls):
7778
7879
7980class InMemoryFeatureStore (FeatureStore ):
81+
8082 def __init__ (self ):
8183 self ._lock = ReadWriteLock ()
8284 self ._initialized = False
@@ -140,6 +142,7 @@ def initialized(self):
140142
141143
142144class LDClient (object ):
145+
143146 def __init__ (self , api_key , config = None ):
144147 check_uwsgi ()
145148 self ._api_key = api_key
@@ -153,12 +156,14 @@ def __init__(self, api_key, config=None):
153156 self ._store = config .feature_store_class ()
154157 """ :type: FeatureStore """
155158
156- self ._feature_requester = config .feature_requester_class (api_key , config )
159+ self ._feature_requester = config .feature_requester_class (
160+ api_key , config )
157161 """ :type: FeatureRequester """
158162
159163 self ._stream_processor = None
160164 if self ._config .stream :
161- self ._stream_processor = config .stream_processor_class (api_key , config , self ._store )
165+ self ._stream_processor = config .stream_processor_class (
166+ api_key , config , self ._store )
162167 self ._stream_processor .start ()
163168
164169 @property
@@ -168,7 +173,8 @@ def api_key(self):
168173 def _check_consumer (self ):
169174 with self ._lock :
170175 if not self ._consumer or not self ._consumer .is_alive ():
171- self ._consumer = self ._config .consumer_class (self ._queue , self ._api_key , self ._config )
176+ self ._consumer = self ._config .consumer_class (
177+ self ._queue , self ._api_key , self ._config )
172178 self ._consumer .start ()
173179
174180 def _stop_consumers (self ):
@@ -188,7 +194,8 @@ def _send(self, event):
188194 self ._queue .put (event )
189195
190196 def track (self , event_name , user , data = None ):
191- self ._send ({'kind' : 'custom' , 'key' : event_name , 'user' : user , 'data' : data })
197+ self ._send ({'kind' : 'custom' , 'key' : event_name ,
198+ 'user' : user , 'data' : data })
192199
193200 def identify (self , user ):
194201 self ._send ({'kind' : 'identify' , 'key' : user ['key' ], 'user' : user })
@@ -227,7 +234,8 @@ def cb(feature):
227234 val = _evaluate (feature , user )
228235 if val is None :
229236 val = default
230- self ._send ({'kind' : 'feature' , 'key' : key , 'user' : user , 'value' : val })
237+ self ._send ({'kind' : 'feature' , 'key' : key ,
238+ 'user' : user , 'value' : val })
231239 return val
232240
233241 if self ._config .stream and self ._store .initialized :
@@ -237,7 +245,8 @@ def cb(feature):
237245 try :
238246 return self ._feature_requester .get (key , cb )
239247 except Exception :
240- log .exception ('Unhandled exception. Returning default value for flag.' )
248+ log .exception (
249+ 'Unhandled exception. Returning default value for flag.' )
241250 return cb (None )
242251
243- __all__ = ['LDClient' , 'Config' ]
252+ __all__ = ['LDClient' , 'Config' ]
0 commit comments