Skip to main content

Python

Python is fully supported by Speedscale. Use this page for Python-specific proxy settings, TLS trust configuration, demo guidance, and the proxymock local workflow.

Kubernetes Sidecar​

When Python runs with the Speedscale sidecar in forward or dual mode, configure the runtime to use the sidecar's forward proxy on 127.0.0.1:4140 unless you changed proxy-out-port.

Typical settings:

export HTTP_PROXY=http://127.0.0.1:4140
export HTTPS_PROXY=http://127.0.0.1:4140

If tls-out is enabled, also trust the Speedscale CA separately, commonly with REQUESTS_CA_BUNDLE for requests-based applications.

See Proxy Modes and TLS Support for the shared sidecar behavior.

Demo App​

  • Public demo: speedscale/mock-lab (languages/python directory)
  • Stack: standard-library Python (no Flask, no Makefile) that calls one downstream, the CNCF projects API at https://demo-api.trafficreplay.com
  • Local run: python3 app.py
  • Traffic generator: ./lab/tests/run_tests.sh --recording

This is the current public Python demo used for local proxymock examples.

proxymock​

Use this path for the fastest Python first success on a developer workstation.

  1. 1. Install and initialize proxymock
    brew install speedscale/tap/proxymock
    proxymock init

    Use browser sign-in by default. Use `proxymock init --api-key <your key>` only for CI or other headless environments.

  2. 2. Clone the demo and start recording
    git clone https://github.com/speedscale/mock-lab
    cd mock-lab/languages/python
    proxymock record -- python3 app.py

    proxymock records the app while it starts the Python service as a child process. The app listens on port 8080 and calls the CNCF projects API downstream.

  3. 3. Generate one real workflow
    ./lab/tests/run_tests.sh --recording

    Run the test driver from the repo root. It drives the requests that become the exported production-style trace.

  4. 4. Stop the recording, then run with mocks
    cd mock-lab/languages/python
    proxymock mock -- python3 app.py

    The mocked run should no longer need live outbound dependencies.

  5. 5. Replay the same traffic against a change
    cd mock-lab/languages/python
    proxymock replay --test-against http://localhost:8080

    Use replay as the regression check before shipping Python changes.

TLS Trust​

The demo app uses the standard-library urllib client and needs no manual CA configuration locally — proxymock injects the trusted bundle for you. For Python applications that use requests, trust the Speedscale certificate bundle with REQUESTS_CA_BUNDLE. See the shared Language Configuration page for the exact command and related options.