|
3 | 3 | from typing import Any
|
4 | 4 |
|
5 | 5 | import sentry_sdk
|
6 |
| -from django.db import close_old_connections |
7 | 6 |
|
8 | 7 | from sentry import features, options
|
9 | 8 | from sentry.issues.grouptype import GroupCategory
|
|
16 | 15 | logger = logging.getLogger(__name__)
|
17 | 16 |
|
18 | 17 |
|
19 |
| -def _get_issue_summary_with_cleanup( |
20 |
| - group: Group, source: SeerAutomationSource |
21 |
| -) -> tuple[dict[str, Any], int]: |
22 |
| - """ |
23 |
| - Wrapper for get_issue_summary that ensures database connections are properly closed. |
24 |
| - This is needed when running in a thread to prevent connection leaks. |
25 |
| - """ |
26 |
| - try: |
27 |
| - return get_issue_summary(group, source=source) |
28 |
| - finally: |
29 |
| - close_old_connections() |
30 |
| - |
31 |
| - |
32 | 18 | def fetch_issue_summary(group: Group) -> dict[str, Any] | None:
|
33 | 19 | """
|
34 | 20 | Try to fetch an issue summary with a timeout of 5 seconds.
|
@@ -66,7 +52,7 @@ def fetch_issue_summary(group: Group) -> dict[str, Any] | None:
|
66 | 52 | with sentry_sdk.start_span(op="ai_summary.fetch_issue_summary_for_alert"):
|
67 | 53 | with concurrent.futures.ThreadPoolExecutor() as executor:
|
68 | 54 | future = executor.submit(
|
69 |
| - _get_issue_summary_with_cleanup, group, SeerAutomationSource.ALERT |
| 55 | + get_issue_summary, group, source=SeerAutomationSource.ALERT |
70 | 56 | )
|
71 | 57 | summary_result, status_code = future.result(timeout=timeout)
|
72 | 58 |
|
|
0 commit comments