# redis-fair-semaphore
基于Redis的信号量。
## Install
```shell
pip install redis-fair-semaphore
```
## 使用方法
```python
import redis
from redis_fair_semaphore import acquire_fair_semaphore
from redis_fair_semaphore import release_fair_semaphore
conn = redis.from_url("redis://redis/0")
def test():
sem_id = acquire_fair_semaphore(conn, "test_sem_name", 10)
try:
if sem_id:
print("Acquired...")
else:
print("NOT acquired...")
finally:
release_fair_semaphore(conn, "test_sem_name", sem_id)
if __name__ == "__main__":
test()
```
## 版本记录
### v0.1.0
- 版本首发。
Raw data
{
"_id": null,
"home_page": null,
"name": "redis-fair-semaphore",
"maintainer": "Zhou KaiQi",
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "fair semaphore",
"author": "Zhou KaiQi",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/85/f3/8cbf7f1f8fc8adf97c23562000711444415ae7b5b5f77affec193e13c7ad/redis-fair-semaphore-0.1.0.tar.gz",
"platform": null,
"description": "# redis-fair-semaphore\n\n\u57fa\u4e8eRedis\u7684\u4fe1\u53f7\u91cf\u3002\n\n## Install\n\n```shell\npip install redis-fair-semaphore\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n```python\nimport redis\nfrom redis_fair_semaphore import acquire_fair_semaphore\nfrom redis_fair_semaphore import release_fair_semaphore\n\nconn = redis.from_url(\"redis://redis/0\")\n\n\ndef test():\n sem_id = acquire_fair_semaphore(conn, \"test_sem_name\", 10)\n try:\n if sem_id:\n print(\"Acquired...\")\n else:\n print(\"NOT acquired...\")\n finally:\n release_fair_semaphore(conn, \"test_sem_name\", sem_id)\n\n\nif __name__ == \"__main__\":\n test()\n```\n\n## \u7248\u672c\u8bb0\u5f55\n\n### v0.1.0\n\n- \u7248\u672c\u9996\u53d1\u3002\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u57fa\u4e8eRedis\u7684\u4fe1\u53f7\u91cf\u3002",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [
"fair",
"semaphore"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5422f8a86c333956409574ac627ceb918547ef9e90867504b7ad679f58d452fb",
"md5": "16e0db422fde90af28d83a11600892ef",
"sha256": "4f50ce5091bc18fb3888638715fe639a926b2b3ce565aed3c125b28ffe770d50"
},
"downloads": -1,
"filename": "redis_fair_semaphore-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "16e0db422fde90af28d83a11600892ef",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 2467,
"upload_time": "2024-06-13T15:17:04",
"upload_time_iso_8601": "2024-06-13T15:17:04.211500Z",
"url": "https://files.pythonhosted.org/packages/54/22/f8a86c333956409574ac627ceb918547ef9e90867504b7ad679f58d452fb/redis_fair_semaphore-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "85f38cbf7f1f8fc8adf97c23562000711444415ae7b5b5f77affec193e13c7ad",
"md5": "842ea726375add76b54ad73c3f61702d",
"sha256": "93d83e371bf83e5f82a7953677b2826f0ce9c4a1a46add13cd42bf342e0d9e17"
},
"downloads": -1,
"filename": "redis-fair-semaphore-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "842ea726375add76b54ad73c3f61702d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3423,
"upload_time": "2024-06-13T15:17:05",
"upload_time_iso_8601": "2024-06-13T15:17:05.997088Z",
"url": "https://files.pythonhosted.org/packages/85/f3/8cbf7f1f8fc8adf97c23562000711444415ae7b5b5f77affec193e13c7ad/redis-fair-semaphore-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-13 15:17:05",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "redis-fair-semaphore"
}