Python in Connect
Python is the one language on Connect's server side. The web application, the realtime voice worker, every test suite and almost every operations tool are Python. The production host runs Python 3.12 in a virtual environment at /opt/connect/venv, and the dependencies come from the repository's requirements files.
What it is#
Python is a general-purpose programming language created by Guido van Rossum and first released in 1991. The reference implementation, CPython, is maintained by the core developers under the Python Software Foundation. A new feature release ships each year, and each release receives about five years of support.
Python suits Connect because nearly every provider Connect talks to publishes a Python SDK or a plain HTTP API: AWS, Google, LiveKit, payment gateways and carriers. Its asyncio model lets one process hold many slow network conversations at once.
- Category
- Programming language and runtime
- Implementation
- CPython
- Version on the host
- 3.12, installed as
python3.12-venvbyops/aws/bootstrap-host.sh - Official site
- python.org
Where Connect uses it#
| Place in Connect | What it does there |
|---|---|
backend/app/ | The web application: every route, model and background job |
backend/voice_worker/ | The realtime voice worker, run as the connect-voice service |
tools/ | Every regression suite, the docs builder, the gates and the release tooling |
ops/ | Host scripts for mail health, backups and the IMAP backup; most host scripts are shell |
How it connects#
requirements*.txtnames the packages- The host's
venvinstalls them under/opt/connect/venv - systemd starts
uvicornandpython -m backend.voice_worker.agentfrom that venv - Both processes read the same
.envand reach the same PostgreSQL
Benefits and limits#
What it gives Connect:
- One language from the database query to the deploy check, so a reader follows a feature without changing mental models.
- Mature SDKs for every provider Connect uses, plus
asynciofor concurrent network work. - The standard library covers
hmac,hashlib,zoneinfo,emailandjson. Webhook signatures and MIME parsing need no extra dependency.
Where it stops, and what Connect does about it:
- The global interpreter lock means one process runs Python code on one core at a time. The voice worker is a separate process for this reason, so a busy web request cannot stall an audio frame.
- CPU-heavy work is slow in pure Python. Connect pushes aggregation into PostgreSQL rather than looping over rows (see query cost).
- Windows lacks a system time-zone database, so
tzdatais a declared dependency (see the locale libraries).
Security and privacy#
- Services run as the unprivileged user
connectwithNoNewPrivileges=true. - Dependencies are installed from the requirements files, and
banditscans the code in the static gate (development tools). - Secrets come from the environment and are never written into the code or these pages.
Licence, cost and versions#
| Question | Answer |
|---|---|
| Licence | Python Software Foundation License (permissive; GPL-compatible) |
| Cost | None for the language. The cost is the server it runs on (AWS hosting) |
| Version | 3.12 on the host. Development checkouts may run a newer 3.x, and the code avoids syntax newer than 3.12 |
| Compatibility | Every package floor in requirements.txt supports 3.12 |
Troubleshooting#
ModuleNotFoundErrorafter a release- A new dependency is in
requirements.txtbut was not installed into/opt/connect/venv. The release script installs requirements, so a manual copy that skipped it is the usual cause. - A time zone such as
Asia/Kolkatais not found - The
tzdatapackage is missing on a system without its own zone database. - Odd characters in logs on Windows
- The services set
PYTHONIOENCODING=utf-8, and local tools should open files withencoding="utf-8".
Official references#
Questions#
Why not Node.js or Go for the server?
The provider SDKs Connect depends on, the data work and the test tooling are strongest in Python, and one language keeps the team's context in one place. The browser side is JavaScript, because that is what browsers run.
Which Python version should a developer use locally?
3.12 matches the host. A newer 3.x works for the suites, but avoid language features newer than 3.12, because the host will refuse to import them.