generic-pool
generic-pool is a generic object pool for python inspired by the node.js library.
You can use it to build your own resource pools, e.g. to manage file handles, connections or similar.
Install
Install generic-pool from pypi using your favourite package manager.
# If you use poetry
poetry add generic-pool
# If you use pip
pip install generic-pool
Usage
from random
from generic_pool import Factory
from generic_pool import Pool
class IntValue:
def __init__(self):
self.value = random.rand
pass
class FortyTwoFactory(Factory):
def create(self) -> IntValue:
return IntValue()
def validate(self, item: IntValue) -> bool:
return item.value == 42
def destroy(self):
# free resources, not applicable here
pass
factory = FortyTwoFactory()
pool = Pool(factory)
item = pool.acquire()
try:
assert item.value == 42
finally:
pool.release(item)
with pool.acquire(item):
assert item.value == 42
License
Release files for generic-pool 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| generic-pool-0.1.2.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| generic_pool-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / generic-pool-0.1.2.tar.gz
| Download URL | generic-pool-0.1.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
520d31261ac9ea3f9b361bd4fb06004d2848b555ede31817910b336f3cbccca4
|
|
BLAKE2b-256 checksum How to use checksums |
1ec89f870141c903f05f22bcac5a2de380a5c4c32b634910fc9b027560037e26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.5 Linux/5.13.0-1031-azure
|
Release files / generic_pool-0.1.2-py3-none-any.whl
| Download URL | generic_pool-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a409e05168aed637616477282a9079bd2fbc0829c42a96226697614e96d11ba1
|
|
BLAKE2b-256 checksum How to use checksums |
19304c5c5f0403b26338ff74124b1b544fa1415ec51220a11e715fc5bdecd418
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.5 Linux/5.13.0-1031-azure
|