Skip to content

Commit 9030702

Browse files
authored
fix(query-awaited): Try increasing timeout, not do threadsafe and add… (#30225)
1 parent 922e172 commit 9030702

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

posthog/api/query.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ async def query_awaited(request: Request, *args, **kwargs) -> StreamingHttpRespo
279279
# This provides better handling of task cancellation than run_in_executor
280280
async_process_query_model = sync_to_async(
281281
process_query_model,
282-
thread_sensitive=False, # Set to False since this doesn't need to run in the same thread as the request
283282
)
284283

285284
# Create a task from the async wrapper
@@ -294,7 +293,7 @@ async def query_awaited(request: Request, *args, **kwargs) -> StreamingHttpRespo
294293
)
295294

296295
# YOLO give the task a moment to materialize (otherwise the task looks like it's been cancelled)
297-
await asyncio.sleep(0.01)
296+
await asyncio.sleep(0.5)
298297

299298
async def event_stream():
300299
assert kwargs.get("team_id") is not None
@@ -316,6 +315,7 @@ async def event_stream():
316315
if query_task.cancelled():
317316
# Explicitly check for cancellation first
318317
yield f"data: {json.dumps({'error': 'Query was cancelled', 'status_code': 499})}\n\n".encode()
318+
capture_exception(Exception("Query was cancelled"))
319319
break
320320
try:
321321
result = query_task.result()

0 commit comments

Comments
 (0)