From 79c5d4fba2b7cd7549cbc56c5145064c8c73fc98 Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Wed, 20 Sep 2023 14:51:16 -0700 Subject: [PATCH] fix: check if future exists before grabbing it --- posthog/api/capture.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/posthog/api/capture.py b/posthog/api/capture.py index c3b45cafef816..9a7bad8d011a0 100644 --- a/posthog/api/capture.py +++ b/posthog/api/capture.py @@ -426,7 +426,8 @@ def get_event(request): start_time = time.monotonic() for future in futures: try: - future.get(timeout=settings.KAFKA_PRODUCE_ACK_TIMEOUT_SECONDS - (time.monotonic() - start_time)) + if future is not None: + future.get(timeout=settings.KAFKA_PRODUCE_ACK_TIMEOUT_SECONDS - (time.monotonic() - start_time)) except KafkaError as exc: # TODO: distinguish between retriable errors and non-retriable # errors, and set Retry-After header accordingly.