Skip to content

Improve Vacation Planner Implementation#93

Merged
paolosalvatori merged 2 commits into
mainfrom
improve-vacation-planner
May 26, 2026
Merged

Improve Vacation Planner Implementation#93
paolosalvatori merged 2 commits into
mainfrom
improve-vacation-planner

Conversation

@paolosalvatori
Copy link
Copy Markdown
Contributor

Motivation

Two cosmetic but recurring runtime issues affect all four vacation-planner web-app samples when running on Azure App Service / Oryx-launched gunicorn:

  1. Exit produces a Python traceback. The default worker_int handler raises SystemExit(0) inside the worker's socket.recv() loop, which unwinds through gunicorn's HTTP parser frames and dumps a misleading stack trace before the process exits.
  2. Worker timeout produces a Python traceback. When a sync worker misses its heartbeat (idle keep-alive connection, slow client, etc.), the arbiter sends SIGABRT. The default worker_abort handler does sys.exit(1), which unwinds through the same recv() stack and prints a stack trace after the genuine [CRITICAL] WORKER TIMEOUT (pid:N) diagnostic line — making logs noisier and harder to read.

Both issues are signal-handling artifacts, not application bugs. The proper fix is to override gunicorn's per-worker signal hooks with os._exit() calls that bypass the Python exception unwind.

Separately, the pinned dependency versions in each requirements.txt had drifted behind the latest stable PyPI releases. Bumping them in the same PR keeps the samples on supported, security-patched dependencies — including gunicorn 26.0.0, the same version used by these hooks.

Changes

New files — each sample gets a src/gunicorn.conf.py with the same two hook overrides. Gunicorn auto-discovers ./gunicorn.conf.py from the working directory on App Service (/home/site/wwwroot), so no Oryx startup-command override is required.

  • web-app-cosmosdb-mongodb-api/python/src/gunicorn.conf.py
  • web-app-cosmosdb-nosql-api/python/src/gunicorn.conf.py
  • web-app-managed-identity/python/src/gunicorn.conf.py
  • web-app-sql-database/python/src/gunicorn.conf.py

Each file defines:

  • worker_int(worker)os._exit(0). Suppresses the SystemExit traceback on SIGINT/SIGQUIT. SIGTERM (graceful shutdown) goes through a different code path and is unaffected.
  • worker_abort(worker)os._exit(1). Suppresses the SystemExit traceback on SIGABRT (worker timeout). The [CRITICAL] WORKER TIMEOUT log line — the genuine diagnostic — is still emitted.

Modified files — each requirements.txt bumped to the latest stable PyPI version per package. Flask, python-dotenv, and pyodbc were already at latest; only behind-versions are listed below.

  • web-app-cosmosdb-mongodb-api/python/src/requirements.txt
    • azure-identity: 1.25.1 → 1.25.3
    • pymongo: 4.15.3 → 4.17.0
    • gunicorn: 23.0.0 → 26.0.0
  • web-app-cosmosdb-nosql-api/python/src/requirements.txt
    • azure-mgmt-cosmosdb: 9.8.0 → 9.9.0
    • azure-cosmos: 4.7.0 → 4.15.0
    • gunicorn: 22.0.0 → 26.0.0
    • setuptools: 79.0.1 → 82.0.1
  • web-app-managed-identity/python/src/requirements.txt
    • azure-identity: 1.16.1 → 1.25.3
    • azure-storage-blob: 12.26.0 → 12.29.0
    • azure-core: 1.38.0 → 1.41.0
    • gunicorn: 23.0.0 → 26.0.0
  • web-app-sql-database/python/src/requirements.txt
    • gunicorn: 25.3.0 → 26.0.0
    • azure-keyvault-secrets: 4.10.0 → 4.11.0
    • azure-keyvault-certificates: 4.10.0 → 4.11.1
    • cryptography: 46.0.7 → 48.0.0

No application code, templates, static assets, scripts, or IaC was touched. Behavior of each sample is unchanged at the request-handling layer; only signal handling and dependency floors move.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Python “Vacation Planner” web-app samples to (1) suppress misleading Gunicorn tracebacks during worker shutdown/timeout by adding per-sample gunicorn.conf.py hooks, and (2) bump pinned dependencies in each sample’s requirements.txt to newer versions.

Changes:

  • Added src/gunicorn.conf.py to each of the four vacation-planner Flask samples, overriding worker_int / worker_abort to call os._exit(...).
  • Updated pinned package versions (notably gunicorn==26.0.0 across all four samples, plus Azure SDK / DB-related deps where applicable).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
samples/web-app-sql-database/python/src/requirements.txt Bumps Gunicorn + Key Vault + cryptography pins for the SQL Database sample.
samples/web-app-sql-database/python/src/gunicorn.conf.py Adds Gunicorn worker signal hooks to avoid tracebacks on exit/timeout.
samples/web-app-managed-identity/python/src/requirements.txt Updates Azure SDK + Gunicorn pins for the Managed Identity sample.
samples/web-app-managed-identity/python/src/gunicorn.conf.py Adds Gunicorn worker signal hooks to avoid tracebacks on exit/timeout.
samples/web-app-cosmosdb-nosql-api/python/src/requirements.txt Updates Cosmos/management SDK + Gunicorn + setuptools pins for the NoSQL sample.
samples/web-app-cosmosdb-nosql-api/python/src/gunicorn.conf.py Adds Gunicorn worker signal hooks to avoid tracebacks on exit/timeout.
samples/web-app-cosmosdb-mongodb-api/python/src/requirements.txt Updates azure-identity/pymongo + Gunicorn pins for the MongoDB API sample.
samples/web-app-cosmosdb-mongodb-api/python/src/gunicorn.conf.py Adds Gunicorn worker signal hooks to avoid tracebacks on exit/timeout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread samples/web-app-sql-database/python/src/gunicorn.conf.py
Comment thread samples/web-app-managed-identity/python/src/gunicorn.conf.py
Comment thread samples/web-app-cosmosdb-mongodb-api/python/src/gunicorn.conf.py
Comment thread samples/web-app-cosmosdb-nosql-api/python/src/gunicorn.conf.py
Copy link
Copy Markdown
Contributor

@DrisDary DrisDary left a comment

Choose a reason for hiding this comment

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

LGTM

@paolosalvatori paolosalvatori merged commit 8614ad1 into main May 26, 2026
20 of 21 checks passed
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

Successfully merging this pull request may close these issues.

4 participants