From 73fce744878d8ec0725fa4a0a7f842eb6d7c6a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Far=C3=ADas=20Santana?= Date: Wed, 4 Sep 2024 19:17:57 +0200 Subject: [PATCH] feat(batch-exports): Send file write to thread (#24792) --- posthog/temporal/batch_exports/temporary_file.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/posthog/temporal/batch_exports/temporary_file.py b/posthog/temporal/batch_exports/temporary_file.py index 75cde8a9b651b..079cce001d235 100644 --- a/posthog/temporal/batch_exports/temporary_file.py +++ b/posthog/temporal/batch_exports/temporary_file.py @@ -1,6 +1,7 @@ """This module contains a temporary file to stage data in batch exports.""" import abc +import asyncio import collections.abc import contextlib import csv @@ -390,7 +391,7 @@ async def write_record_batch(self, record_batch: pa.RecordBatch) -> None: column_names = record_batch.column_names column_names.pop(column_names.index("_inserted_at")) - self._write_record_batch(record_batch.select(column_names)) + await asyncio.to_thread(self._write_record_batch, record_batch.select(column_names)) self.last_inserted_at = last_inserted_at self.track_records_written(record_batch)