Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dev workers #27095

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions posthog/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,9 @@ def calculate_decide_usage() -> None:

ph_client = get_ph_client()

capture_decide_usage_for_all_teams(ph_client)

ph_client.shutdown()
if ph_client:
capture_decide_usage_for_all_teams(ph_client)
ph_client.shutdown()


@shared_task(ignore_result=True)
Expand Down
35 changes: 20 additions & 15 deletions posthog/tasks/warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@ def capture_workspace_rows_synced_by_team(team_id: int) -> None:
team.external_data_workspace_last_synced_at = now

for job in ExternalDataJob.objects.filter(team_id=team_id, created_at__gte=begin).order_by("created_at").all():
ph_client.capture(
team_id,
"$data_sync_job_completed",
{
"team_id": team_id,
"workspace_id": team.external_data_workspace_id,
"count": job.rows_synced,
"start_time": job.created_at,
"job_id": str(job.pk),
},
)
if ph_client:
ph_client.capture(
team_id,
"$data_sync_job_completed",
{
"team_id": team_id,
"workspace_id": team.external_data_workspace_id,
"count": job.rows_synced,
"start_time": job.created_at,
"job_id": str(job.pk),
},
)

team.external_data_workspace_last_synced_at = job.created_at

team.save()

ph_client.shutdown()
if ph_client:
ph_client.shutdown()


@shared_task(ignore_result=True)
Expand All @@ -66,14 +68,17 @@ def validate_data_warehouse_table_columns(team_id: int, table_id: str) -> None:
table.columns[column]["valid"] = table.validate_column_type(column)
table.save()

ph_client.capture(team_id, "validate_data_warehouse_table_columns succeeded")
if ph_client:
ph_client.capture(team_id, "validate_data_warehouse_table_columns succeeded")
except Exception as e:
logger.exception(
f"validate_data_warehouse_table_columns raised an exception for table: {table_id}",
exc_info=e,
team_id=team_id,
)

ph_client.capture(team_id, "validate_data_warehouse_table_columns errored")
if ph_client:
ph_client.capture(team_id, "validate_data_warehouse_table_columns errored")
finally:
ph_client.shutdown()
if ph_client:
ph_client.shutdown()
Loading