Skip to content

Commit f8cdca5

Browse files
committed
feat: log-runtime-error
1 parent f6a84cf commit f8cdca5

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

flagsmith/analytics.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,20 @@ def flush(self) -> None:
168168
payload = json.dumps(
169169
{"events": events, "environment_key": self._environment_key}
170170
)
171-
future = session.post(
172-
self._batch_endpoint,
173-
data=payload,
174-
timeout=3,
175-
headers={
176-
"Content-Type": "application/json; charset=utf-8",
177-
"X-Environment-Key": self._environment_key,
178-
"Flagsmith-SDK-User-Agent": f"flagsmith-python-client/{__version__}",
179-
},
180-
)
171+
try:
172+
future = session.post(
173+
self._batch_endpoint,
174+
data=payload,
175+
timeout=3,
176+
headers={
177+
"Content-Type": "application/json; charset=utf-8",
178+
"X-Environment-Key": self._environment_key,
179+
"Flagsmith-SDK-User-Agent": f"flagsmith-python-client/{__version__}",
180+
},
181+
)
182+
except RuntimeError:
183+
logger.debug("Skipping flush: thread pool already shut down")
184+
return
181185
future.add_done_callback(lambda f: self._handle_flush_result(f, events))
182186

183187
def _handle_flush_result(

0 commit comments

Comments
 (0)