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: trying garbage collection in celery post-run #75

Merged
merged 1 commit into from
Jun 26, 2024
Merged
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
5 changes: 5 additions & 0 deletions celery_app/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from typing import Any

from celery.signals import task_postrun
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

Ensure robust exception handling and environment configuration.

The environment variable TRACELOOP_BASE_URL is used directly in celery_app/tasks.py without validation. To avoid potential runtime errors, please add proper checks to validate this environment variable before using it.

  • File: celery_app/tasks.py
  • Line: otel_endpoint = os.getenv("TRACELOOP_BASE_URL")
Analysis chain

Ensure robust exception handling and environment configuration.

Given the complexity of ask_question_auto_search, which interacts with external services, it's crucial to ensure that all potential points of failure are gracefully handled. Additionally, consider validating the environment variables (TRACELOOP_BASE_URL) before use to avoid runtime errors.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all environment variables are validated before use.

# Test: Search for the environment variable usage. Expect: Proper checks before usage.
rg --type python $'os.getenv("TRACELOOP_BASE_URL")'

Length of output: 83



Script:

#!/bin/bash
# Description: Verify that all environment variables are validated before use.

# Test: Search for the environment variable usage. Expect: Proper checks before usage.
rg --type py 'os.getenv("TRACELOOP_BASE_URL")'

Length of output: 48



Script:

#!/bin/bash
# Description: Verify that all environment variables are validated before use.

# Test: Search for all environment variable usage. Expect: Proper checks before usage.
rg --type py 'os.getenv'

Length of output: 1825



Script:

#!/bin/bash
# Description: Verify that environment variable TRACELOOP_BASE_URL is validated before use.

# Test: Search for the usage of TRACELOOP_BASE_URL and check for validation or error handling mechanisms.
rg --context 5 'os.getenv("TRACELOOP_BASE_URL")' celery_app/tasks.py

Length of output: 70



Script:

#!/bin/bash
# Description: Directly output the relevant lines in celery_app/tasks.py where TRACELOOP_BASE_URL is used.

# Test: Search for the usage of TRACELOOP_BASE_URL in celery_app/tasks.py.
rg 'TRACELOOP_BASE_URL' celery_app/tasks.py -A 5 -B 5

Length of output: 491

from celery_app.server import app
from celery_app.utils.fire_event import job_send
from dotenv import load_dotenv
Expand Down Expand Up @@ -122,4 +123,8 @@ def ask_question_auto_search(
content=response_payload,
)


@task_postrun.connect
def task_postrun_handler(sender=None, **kwargs):
# Trigger garbage collection after each task
gc.collect()
Loading