Python client for AgileConfig with WebSocket updates and environment fallback
Project description
agileconfig-python
Python client for AgileConfig. The client loads configuration over HTTP, listens for reload notifications over WebSocket, and falls back to os.environ when the server is unavailable.
Installation
python -m pip install agileconfig-python
Usage
from agileconfig_python import AgileConfigLoader
loader = AgileConfigLoader(
url="wss://config.example.com/ws",
app_id="my-app",
secret="your-secret",
env="DEV",
)
database_host = str(loader.get_var("host", prefix="database"))
loader.stop()
The initial HTTP request populates the cache. When AgileConfig publishes a reload event, the cache is refreshed. If the server cannot be reached within the configured timeout, get_var_value reads the variable name from the process environment and ignores its prefix.
Singleton behavior and safety notes
AgileConfigLoader is a process-wide singleton. Creating it multiple times in the same Python process returns the same instance and does not reinitialize it.
Important implications:
- Do not assume a second
AgileConfigLoader(...)call with different credentials or URL will switch connections. The first initialization wins for the process lifetime. - Avoid creating loaders in many modules with different parameters. Prefer one startup location and reuse that instance.
- Calling
loader.stop()stops the shared background listener for the singleton. Other parts of your app using the same loader will stop receiving updates. - In tests, call
stop()during teardown to avoid background-thread leakage across test cases. - If your process forks workers, create the loader inside each worker process after fork, not in the parent before fork.
API
AgileConfigLoader(url, app_id, secret, env)creates the singleton loader and starts its listener.loader.get_var_value(var_name, prefix="")returns the current value, or an environment fallback.loader.get_var(var_name, prefix="")returns a lazy string-like proxy that reads the latest value when converted withstr().loader.stop()closes the WebSocket and stops the listener thread.
Development
python -m pip install --upgrade pip build
python -m pip install -e .
python -m unittest discover -s unit_tests -v
python -m build
The live integration tests embedded in the source require an AgileConfig server and are not run by the offline unit-test command.
Release checklist
- Update
versioninpyproject.toml. - Run the unit tests and
python -m build. - Inspect both artifacts with
python -m twine check dist/*. - Upload to TestPyPI and install the uploaded version in a clean environment.
- Create a Git tag matching the version, for example
v0.1.0. - Publish to PyPI with a trusted publisher or
twine upload dist/*.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agileconfig_python-0.1.4.tar.gz.
File metadata
- Download URL: agileconfig_python-0.1.4.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8ffd83d8b35a1b0f99da0ea56d9f342ab0a544b96ce748637d68876a1382a3e
|
|
| MD5 |
8ebdc39382cdb6bd98dc7277e73e9cfc
|
|
| BLAKE2b-256 |
d6dd611fe312c0878bb89f2c62b63c1792c48f9dc36214c145a1c1c22b5999b4
|
Provenance
The following attestation bundles were made for agileconfig_python-0.1.4.tar.gz:
Publisher:
publish.yml on IshootLaser/agileconfig-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agileconfig_python-0.1.4.tar.gz -
Subject digest:
a8ffd83d8b35a1b0f99da0ea56d9f342ab0a544b96ce748637d68876a1382a3e - Sigstore transparency entry: 2257386077
- Sigstore integration time:
-
Permalink:
IshootLaser/agileconfig-python@c49fd215da43e333993af6644078cc6f8dedb59a -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/IshootLaser
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c49fd215da43e333993af6644078cc6f8dedb59a -
Trigger Event:
push
-
Statement type:
File details
Details for the file agileconfig_python-0.1.4-py3-none-any.whl.
File metadata
- Download URL: agileconfig_python-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9aed5c68da198d75b8e6975dadad4ee5ddbb13a459fdd4e239268e00a1a1131
|
|
| MD5 |
4c3aaf3f8e5291d750edca2632bcc32c
|
|
| BLAKE2b-256 |
253034aa12c1543e56f6209d06045a98e92ca89813ad138fe894624dc08470c4
|
Provenance
The following attestation bundles were made for agileconfig_python-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on IshootLaser/agileconfig-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agileconfig_python-0.1.4-py3-none-any.whl -
Subject digest:
a9aed5c68da198d75b8e6975dadad4ee5ddbb13a459fdd4e239268e00a1a1131 - Sigstore transparency entry: 2257386080
- Sigstore integration time:
-
Permalink:
IshootLaser/agileconfig-python@c49fd215da43e333993af6644078cc6f8dedb59a -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/IshootLaser
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c49fd215da43e333993af6644078cc6f8dedb59a -
Trigger Event:
push
-
Statement type: