Skip to content

Commit cde6cfb

Browse files
authoredOct 1, 2024
fix: Shutdown diagnostic thread if enabled (#312)
1 parent ec74ff8 commit cde6cfb

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
 

‎ldclient/impl/events/event_processor.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class DebugEvent:
4444
def __init__(self, original_input: EventInputEvaluation):
4545
self.original_input = original_input
4646

47+
4748
class IndexEvent:
4849
__slots__ = ['timestamp', 'context']
4950

@@ -57,7 +58,7 @@ def __init__(self, config: Config):
5758
self._context_formatter = EventContextFormatter(config.all_attributes_private, config.private_attributes)
5859

5960
def make_output_events(self, events: List[Any], summary: EventSummary):
60-
events_out = [ self.make_output_event(e) for e in events ]
61+
events_out = [self.make_output_event(e) for e in events]
6162
if not summary.is_empty():
6263
events_out.append(self.make_summary_event(summary))
6364
return events_out
@@ -163,10 +164,10 @@ def make_output_event(self, e: Any):
163164

164165
return None
165166

166-
"""
167-
Transform summarizer data into the format used for the event payload.
168-
"""
169167
def make_summary_event(self, summary: EventSummary):
168+
"""
169+
Transform summarizer data into the format used for the event payload.
170+
"""
170171
flags_out = dict() # type: Dict[str, Any]
171172
for key, flag_data in summary.flags.items():
172173
flag_data_out = {'default': flag_data.default, 'contextKinds': list(flag_data.context_kinds)}
@@ -246,7 +247,7 @@ def run(self):
246247
def _do_send(self, output_events):
247248
# noinspection PyBroadException
248249
try:
249-
json_body = json.dumps(output_events, separators=(',',':'))
250+
json_body = json.dumps(output_events, separators=(',', ':'))
250251
log.debug('Sending events payload: ' + json_body)
251252
payload_id = str(uuid.uuid4())
252253
r = _post_events_with_retry(
@@ -442,8 +443,6 @@ def _get_indexable_context(self, event: EventInput, block: Callable[[Context], N
442443

443444
block(context)
444445

445-
446-
447446
def _should_debug_event(self, event: EventInputEvaluation):
448447
if event.flag is None:
449448
return False
@@ -492,6 +491,11 @@ def _send_and_reset_diagnostics(self):
492491
def _do_shutdown(self):
493492
self._flush_workers.stop()
494493
self._flush_workers.wait()
494+
495+
if self._diagnostic_flush_workers:
496+
self._diagnostic_flush_workers.stop()
497+
self._diagnostic_flush_workers.wait()
498+
495499
if self._close_http:
496500
self._http.clear()
497501

0 commit comments

Comments
 (0)