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

GENERATOR_STATS is not thread-safe #1368

Open
petersalas opened this issue Jan 17, 2025 · 0 comments
Open

GENERATOR_STATS is not thread-safe #1368

petersalas opened this issue Jan 17, 2025 · 0 comments

Comments

@petersalas
Copy link

Describe the bug
GENERATOR_STATS is a singleton (with global class attributes) but is mutated freely. If the schema (with errors or warnings) is generated concurrently (e.g. by SpectacularAPIView) exceptions and/or invalid traces can occur.

To Reproduce
Create a schema with at least one warning or error, add an API view and then run

while true; do
    if ! curl http://localhost:8000/api/schema/ -s --fail > /dev/null; then
        break
    fi
done

in multiple bash shells against the schema URL in parallel -- eventually requests will fail.

Expected behavior
API views and schema generation are thread-safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant