forked from SPSCommerce/redlock-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
88 lines (73 loc) · 2.18 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- coding: utf-8 -*-
import os
# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
from setuptools import setup, find_packages
README = '''
pyredlock - A Redis distributed lock implementation in Python
This python lib implements the Redis-based distributed lock manager algorithm [described in this blog post](https://redis.io/docs/manual/patterns/distributed-locks/).
### How to use it?
To create a lock manager:
```python
from pyredlock import RedisClient
from pyredlock import Redlock, Lock
...
client = RedisClient(client_conf={
"endpoint": "localhost:6379",
"password": "your_redis_password",
"db": 0,
"socket_timeout": 0.5,
"socket_connect_timeout": 0.25
})
lock_mgr = Redlock(connections=[client.get_connection()], async_mode=False)
...
```
To acquire a lock:
```python
...
success, my_lock = lock_mgr.lock("my_resource_name", 1000)
...
```
To release a lock:
```python
...
lock_mgr.unlock(my_lock)
...
```
To extend your ownership of a lock that you already own:
```python
...
lock_mgr.extend(my_lock, 1000)
...
```
**Disclaimer**: This implementation is currently a proposal, it was not formally analyzed. Make sure to understand how it works before using it in your production environments.
'''
setup(
name='pyredlock',
version='1.0.0',
description='A Redis distributed lock implementation in Python',
long_description=README,
long_description_content_type='text/markdown',
author='Adam Zhou',
author_email='adamzhouisnothing@gmail.com',
url='https://github.com/amazingchow/redlock-py',
packages=find_packages(),
include_package_data=True,
install_requires=[
"jsonschema==4.20.0",
"loguru==0.7.2",
"redis==5.0.1"
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
entry_points={
'console_scripts': []
}
)