fb-python-sdk 1.1.1__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {fb-python-sdk-1.1.1/fb_python_sdk.egg-info → fb-python-sdk-1.1.2}/PKG-INFO +3 -3
  2. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/README.md +3 -3
  3. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2/fb_python_sdk.egg-info}/PKG-INFO +3 -3
  4. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fb_python_sdk.egg-info/SOURCES.txt +1 -0
  5. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/client.py +1 -2
  6. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/event_processor.py +23 -11
  7. fb-python-sdk-1.1.2/fbclient/version.py +1 -0
  8. fb-python-sdk-1.1.2/intergration_tests/readme.py +25 -0
  9. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/intergration_tests/run_in_start_no_wait.py +1 -1
  10. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/intergration_tests/run_in_start_wait.py +2 -2
  11. fb-python-sdk-1.1.1/fbclient/version.py +0 -1
  12. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/LICENSE +0 -0
  13. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/MANIFEST.in +0 -0
  14. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/dev-requirements.txt +0 -0
  15. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fb_python_sdk.egg-info/dependency_links.txt +0 -0
  16. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fb_python_sdk.egg-info/requires.txt +0 -0
  17. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fb_python_sdk.egg-info/top_level.txt +0 -0
  18. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/__init__.py +0 -0
  19. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/category.py +0 -0
  20. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/common_types.py +0 -0
  21. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/config.py +0 -0
  22. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/data_storage.py +0 -0
  23. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/evaluator.py +0 -0
  24. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/event_types.py +0 -0
  25. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/interfaces.py +0 -0
  26. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/status.py +0 -0
  27. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/status_types.py +0 -0
  28. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/streaming.py +0 -0
  29. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/update_processor.py +0 -0
  30. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/utils/__init__.py +0 -0
  31. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/utils/exponential_backoff_jitter_strategy.py +0 -0
  32. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/utils/http_client.py +0 -0
  33. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/utils/repeatable_task.py +0 -0
  34. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/utils/rwlock.py +0 -0
  35. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/fbclient/utils/variation_splitting_algorithm.py +0 -0
  36. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/intergration_tests/__init__.py +0 -0
  37. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/pyproject.toml +0 -0
  38. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/requirements.txt +0 -0
  39. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/setup.cfg +0 -0
  40. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/setup.py +0 -0
  41. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/tests/__init__.py +0 -0
  42. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/tests/test_data_storage.py +0 -0
  43. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/tests/test_data_update_status_provider.py +0 -0
  44. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/tests/test_evaluator.py +0 -0
  45. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/tests/test_event_processor.py +0 -0
  46. {fb-python-sdk-1.1.1 → fb-python-sdk-1.1.2}/tests/test_fbclient.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fb-python-sdk
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: A Python SDK for FeatBit plateform
5
5
  Home-page: https://github.com/featbit/featbit-python-sdk
6
6
  Author: Dian SUN
@@ -62,7 +62,7 @@ from fbclient.config import Config
62
62
 
63
63
  env_secret = '<replace-with-your-env-secret>'
64
64
  event_url = 'http://localhost:5100'
65
- streaming_url = '"ws://localhost:5100"'
65
+ streaming_url = 'ws://localhost:5100'
66
66
 
67
67
  set_config(Config(env_secret, event_url, streaming_url))
68
68
  client = get()
@@ -73,7 +73,7 @@ if client.initialize:
73
73
  user_name = 'bot'
74
74
  user = {'key': user_key, 'name': user_name}
75
75
  detail = client.variation_detail(flag_key, user, default=None)
76
- print(f'flag {flag_key} returns {detail.value} for user {user_key}, reason: {detail.reason}')
76
+ print(f'flag {flag_key} returns {detail.variation} for user {user_key}, reason: {detail.reason}')
77
77
 
78
78
  # ensure that the SDK shuts down cleanly and has a chance to deliver events to FeatBit before the program exits
79
79
  client.stop()
@@ -36,7 +36,7 @@ from fbclient.config import Config
36
36
 
37
37
  env_secret = '<replace-with-your-env-secret>'
38
38
  event_url = 'http://localhost:5100'
39
- streaming_url = '"ws://localhost:5100"'
39
+ streaming_url = 'ws://localhost:5100'
40
40
 
41
41
  set_config(Config(env_secret, event_url, streaming_url))
42
42
  client = get()
@@ -47,7 +47,7 @@ if client.initialize:
47
47
  user_name = 'bot'
48
48
  user = {'key': user_key, 'name': user_name}
49
49
  detail = client.variation_detail(flag_key, user, default=None)
50
- print(f'flag {flag_key} returns {detail.value} for user {user_key}, reason: {detail.reason}')
50
+ print(f'flag {flag_key} returns {detail.variation} for user {user_key}, reason: {detail.reason}')
51
51
 
52
52
  # ensure that the SDK shuts down cleanly and has a chance to deliver events to FeatBit before the program exits
53
53
  client.stop()
@@ -185,4 +185,4 @@ otherwise, the custom event may not be included into the experiment result.
185
185
  feature, [submit an issue](https://github.com/featbit/featbit-python-sdk/issues/new).
186
186
 
187
187
  ## See Also
188
- - [Connect To Python Sdk](https://docs.featbit.co/docs/getting-started/4.-connect-an-sdk/server-side-sdks/python-sdk)
188
+ - [Connect To Python Sdk](https://docs.featbit.co/docs/getting-started/4.-connect-an-sdk/server-side-sdks/python-sdk)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fb-python-sdk
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: A Python SDK for FeatBit plateform
5
5
  Home-page: https://github.com/featbit/featbit-python-sdk
6
6
  Author: Dian SUN
@@ -62,7 +62,7 @@ from fbclient.config import Config
62
62
 
63
63
  env_secret = '<replace-with-your-env-secret>'
64
64
  event_url = 'http://localhost:5100'
65
- streaming_url = '"ws://localhost:5100"'
65
+ streaming_url = 'ws://localhost:5100'
66
66
 
67
67
  set_config(Config(env_secret, event_url, streaming_url))
68
68
  client = get()
@@ -73,7 +73,7 @@ if client.initialize:
73
73
  user_name = 'bot'
74
74
  user = {'key': user_key, 'name': user_name}
75
75
  detail = client.variation_detail(flag_key, user, default=None)
76
- print(f'flag {flag_key} returns {detail.value} for user {user_key}, reason: {detail.reason}')
76
+ print(f'flag {flag_key} returns {detail.variation} for user {user_key}, reason: {detail.reason}')
77
77
 
78
78
  # ensure that the SDK shuts down cleanly and has a chance to deliver events to FeatBit before the program exits
79
79
  client.stop()
@@ -32,6 +32,7 @@ fbclient/utils/repeatable_task.py
32
32
  fbclient/utils/rwlock.py
33
33
  fbclient/utils/variation_splitting_algorithm.py
34
34
  intergration_tests/__init__.py
35
+ intergration_tests/readme.py
35
36
  intergration_tests/run_in_start_no_wait.py
36
37
  intergration_tests/run_in_start_wait.py
37
38
  tests/__init__.py
@@ -92,10 +92,9 @@ class FBClient:
92
92
  if not isinstance(self._update_processor, NullUpdateProcessor):
93
93
  log.info("FB Python SDK: Waiting for Client initialization in %s seconds" % str(start_wait))
94
94
 
95
+ update_processor_ready.wait(start_wait)
95
96
  if isinstance(self._data_storage, NullDataStorage) or (not self._data_storage.initialized and not self._config.is_offline):
96
97
  log.warning("FB Python SDK: SDK just returns default variation because of no data found in the given environment")
97
-
98
- update_processor_ready.wait(start_wait)
99
98
  if not self._update_processor.initialized:
100
99
  log.warning("FB Python SDK: SDK was not successfully initialized")
101
100
  else:
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  from concurrent.futures import ThreadPoolExecutor
3
3
  from queue import Empty, Queue
4
- from threading import BoundedSemaphore, Lock, Thread
4
+ from threading import BoundedSemaphore, Condition, Lock, Thread
5
5
  from typing import List, Optional
6
6
 
7
7
  from fbclient.common_types import FBEvent
@@ -76,7 +76,7 @@ class DefaultEventProcessor(EventProcessor):
76
76
  log.info('FB Python SDK: event processor is stopping')
77
77
  self.__closed = True
78
78
  self.__flush_task.stop()
79
- self.flush()
79
+ self.__put_message_async(MessageType.FLUSH)
80
80
  self.__put_message_and_wait_terminate(MessageType.SHUTDOWN)
81
81
 
82
82
 
@@ -94,6 +94,7 @@ class EventDispatcher(Thread):
94
94
  self.__events_buffer_to_next_flush = []
95
95
  self.__flush_workers = ThreadPoolExecutor(max_workers=self.__MAX_FLUSH_WORKERS_NUMBER)
96
96
  self.__permits = BoundedSemaphore(value=self.__MAX_FLUSH_WORKERS_NUMBER)
97
+ self.__lock = Condition(Lock())
97
98
 
98
99
  # blocks until at least one message is available and then:
99
100
  # 1: transfer the events to event buffer
@@ -137,6 +138,11 @@ class EventDispatcher(Thread):
137
138
  self.__events_buffer_to_next_flush.append(event)
138
139
 
139
140
  def __trigger_flush(self):
141
+ def flush_payload_done(fn):
142
+ self.__permits.release()
143
+ with self.__lock:
144
+ self.__lock.notify_all()
145
+
140
146
  if not self.__closed and len(self.__events_buffer_to_next_flush) > 0:
141
147
  log.debug('trigger flush')
142
148
  # get all the current events from event buffer
@@ -146,21 +152,27 @@ class EventDispatcher(Thread):
146
152
  # get an available flush worker to send events
147
153
  self.__flush_workers \
148
154
  .submit(FlushPayloadRunner(self.__config, self.__sender, payloads).run) \
149
- .add_done_callback(lambda x: self.__permits.release())
155
+ .add_done_callback(flush_payload_done)
150
156
  # clear the buffer for the next flush
151
157
  self.__events_buffer_to_next_flush.clear()
152
158
  # if no available flush worker, keep the events in the buffer
153
159
 
154
160
  def __shutdown(self):
155
161
  if not self.__closed:
156
- try:
157
- log.debug('event dispatcher is cleaning up thread and conn pool')
158
- self.__closed = True
159
- log.debug('flush worker pool is stopping...')
160
- self.__flush_workers.shutdown(wait=True)
161
- self.__sender.stop()
162
- except Exception as e:
163
- log.exception('FB Python SDK: unexpected error when closing event dispatcher: %s' % str(e))
162
+ with self.__lock:
163
+ try:
164
+ log.debug('event dispatcher is cleaning up thread and conn pool')
165
+ self.__wait_until_flush_playload_worker_down()
166
+ self.__closed = True
167
+ log.debug('flush worker pool is stopping...')
168
+ self.__flush_workers.shutdown(wait=True)
169
+ self.__sender.stop()
170
+ except Exception as e:
171
+ log.exception('FB Python SDK: unexpected error when closing event dispatcher: %s' % str(e))
172
+
173
+ def __wait_until_flush_playload_worker_down(self):
174
+ while self.__permits._value != self.__MAX_FLUSH_WORKERS_NUMBER:
175
+ self.__lock.wait()
164
176
 
165
177
 
166
178
  class FlushPayloadRunner:
@@ -0,0 +1 @@
1
+ VERSION = "1.1.2"
@@ -0,0 +1,25 @@
1
+ import logging
2
+ from fbclient import get, set_config
3
+ from fbclient.config import Config
4
+
5
+ logging.basicConfig(level=logging.DEBUG,
6
+ format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
7
+ datefmt='%m-%d %H:%M')
8
+
9
+ env_secret = 'fXWjg00OTEa-M_iBCyYiBwFPfdBisjAkiY3ycIMOWw1Q'
10
+ event_url = 'http://localhost:5100'
11
+ streaming_url = 'ws://localhost:5100'
12
+
13
+ set_config(Config(env_secret, event_url, streaming_url))
14
+ client = get()
15
+
16
+ if client.initialize:
17
+ flag_key = 'ff-test-bool'
18
+ user_key = 'user-test-1'
19
+ user_name = 'user-test-1'
20
+ user = {'key': user_key, 'name': user_name}
21
+ detail = client.variation_detail(flag_key, user, default=None)
22
+ print(f'flag {flag_key} returns {detail.variation} for user {user_key}, reason: {detail.reason}')
23
+
24
+ # ensure that the SDK shuts down cleanly and has a chance to deliver events to FeatBit before the program exits
25
+ client.stop()
@@ -10,7 +10,7 @@ logging.basicConfig(level=logging.DEBUG,
10
10
  format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
11
11
  datefmt='%m-%d %H:%M')
12
12
 
13
- env_secret = '9T0GABTXokagxhUZ81hUnws9_E2uOpIEyTjScBRr6JKA'
13
+ env_secret = 'fXWjg00OTEa-M_iBCyYiBwFPfdBisjAkiY3ycIMOWw1Q'
14
14
 
15
15
  config = Config(env_secret, event_url='http://localhost:5100', streaming_url='ws://localhost:5100')
16
16
  client = FBClient(config, start_wait=0)
@@ -10,7 +10,7 @@ logging.basicConfig(level=logging.DEBUG,
10
10
  format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
11
11
  datefmt='%m-%d %H:%M')
12
12
 
13
- env_secret = '9T0GABTXokagxhUZ81hUnws9_E2uOpIEyTjScBRr6JKA'
13
+ env_secret = 'fXWjg00OTEa-M_iBCyYiBwFPfdBisjAkiY3ycIMOWw1Q'
14
14
 
15
15
  config = Config(env_secret, event_url='http://localhost:5100', streaming_url='ws://localhost:5100')
16
16
 
@@ -19,7 +19,7 @@ set_config(config)
19
19
  client = get()
20
20
 
21
21
  if client.initialize:
22
- # client.identify({'key': 'test-python-sdk-user', 'name': 'test-python-sdk-user'})
22
+ client.identify({'key': 'test-python-sdk-user', 'name': 'test-python-sdk-user'})
23
23
  while True:
24
24
  line = input('input user key and flag key seperated by / \n')
25
25
  if 'exit' == line.strip():
@@ -1 +0,0 @@
1
- VERSION = "1.1.1"
File without changes
File without changes
File without changes
File without changes