Skip to content

core dump after migrating from legacy python SDK, observed in GitHub Actions CI #20

@kujenga

Description

@kujenga

We've been using the "legacy" statsig python SDK and I attempted to upgrade to the latest statsig-python-core library. Unfortunately when doing so, our tests in GitHub Actions CI start to core dump with the following error message:

FATAL: exception not rethrown
/home/runner/work/_temp/9397c863-78a9-4d87-83fc-ec3e5dc6281a.sh: line 1:  3763 Aborted                 (core dumped) pytest . -v -n=4 --junitxml=junit.xml --cov=src --cov-report=xml

I don't have much detail at this point beyond this error message and the fact that the only change in the PR where this started happening is updating to the latest library and switching over API usage. If you have any reference points on how to debug this or what might be causing it that would be most appreciated.

Ideally it would not be possible for this library to crash our whole process.

Relevant context

  • Issue first observed with SDK version: 0.3.3
  • Issue still observed with latest SDK version: 0.9.1
  • Framework being initialized within: Django

Initialization logic we use (and shutdown_feature_flags is not called in tests):

_statsig_global: Statsig | None = None


def _statsig() -> Statsig:
    global _statsig_global

    assert sg is not None "Statsig must be created"
    assert sg.is_initialized(), "Statsig must be initialized"
    return sg


def start_feature_flags():
    global _statsig_global

    start_time = time.perf_counter()

    secret_key = settings.STATSIG_SECRET_KEY

    opts = StatsigOptions(
        # See available options here:
        # https://docs.statsig.com/server-core/python-core/#statsig-options
        output_log_level=settings.STATSIG_LOG_LEVEL,
        environment=settings.STATSIG_ENVIRONMENT,
        # Set to a high but non-zero value
        init_timeout_ms=30_000,
    )
    # If statsig is not enabled, we set it up in local mode with a dummy key.
    if not settings.STATSIG_ENABLE:
        secret_key = "secret-INVALID_DEFAULT"
        opts.disable_network = True

    _statsig_global = Statsig(secret_key, options=opts)
    _statsig_global.initialize().wait()


def shutdown_feature_flags():
    _statsig().shutdown()

Django app config for initialization:

import atexit

from django.apps import AppConfig

from myproject.flags import shutdown_feature_flags, start_feature_flags
from myproject.tracing import instrument_app

class ExampleConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "example"

    def ready(self):
        start_feature_flags()
        atexit.register(shutdown_feature_flags)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions