A tiny database de-multiplexer primarily scoped for Web- / Application Server.
Project description
Python PgDatabase-Pool Module
1. Primary Scope
The pgdbpool Python Module is a tiny PostgreSQL Database Connection De-Multiplexer primarily scoped for Web- / Application Server.
2. Current Implementation
+----------------------+ +--------------- - - -
| WebServer Service.py | -- Handler Con #1 ----> | PostgreSQL
| Request / Thread #1 | | Backend
+----------------------+ |
|
+----------------------+ |
| WebServer Service.py | -- Handler Con #2 ----> |
| Request / Thread #2 | |
+----------------------+ +--------------- - - -
2.1. Concept / Simplicity
If configured in a Web-Servers WSGI Python Script, the Pooling-Logic is quite simple.
- Check if a free connection in the pool exists
- Check if connection usable (SQL ping)
- Use connection and protect it from beeing used until querie(s) finished
- Release connection for usage again
- Try reconnecting to endpoint if connection has been lost
3. Thread Safety / Global Interpreter Lock
Currently Thread Safety is guaranteed by lock = threading.Lock()
which implies a Kernel Mutex syscall().
The concept works, but the GIL (Python Global Interpreter Lock) thwarts our plans 😞.
In detail: if used in a threaded Web-Server setup, it does not really scale well on heavy loads.
[!IMPORTANT] Take a closer look at "6. Future", problem solved probably.
4. Dependencies / Installation
Python 3 and psycopg2 module is required.
# apt-get install python3-psycopg2
# pip install pgdbpool
5. Documentation / Examples
See documentation ./doc for detailed explanation / illustrative examples.
6. Future
DB-Pooling also should be usable in FalconAS Python Application Server (https://github.com/WEBcodeX1/http-1.2/).
The model here: 1 Process == 1 Python Interpreter (threading-less), GIL Problem solved :grin:.
[!NOTE] Also a Pool should be configurable to use multiple (read-loadbalanced) PostgreSQL Endpoints.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pgdbpool-0.97rc1.tar.gz
.
File metadata
- Download URL: pgdbpool-0.97rc1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b1bd604432347f974524938b5673e94835b98cfbb4bf87ace9d2f9cb247d9d3 |
|
MD5 | e07da94034a925670f736fee25d498fe |
|
BLAKE2b-256 | f0a8870e407f65719c9a098285494d4df86a9fffd35a42b61cb670af68d00b6e |