具有共享/分布式锁的本地资源分配
resource-locker的Python项目详细描述
#资源柜
请一次一个!
[![Circleci](https://circleci.com/gh/armmbed/resource\u locker.svg?style=shield&circle token=992df378a72010c9b4ed32c14c1354cda9664d2)(https://circleci.com/gh/armmbed/resource\u locker)
[![覆盖范围](https://img.shields.io/badge/coverage-100%25 brightgreen.svg)(https://circleci.com/gh/armmbed/resource\u locker)
[![欢迎投稿](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat](https://github.com/armmbed/resource撸locker)
或类似的方法)。
资源被假定为可被打算使用它们的客户发现和筛选。
这减少了代表客户对资源进行分类和筛选的需要,与具有所有资源数据库的资源分配系统(通常只有资源
服务器执行发现)相比,
数据库n是的**客户端数量)
实际上,目的是在受约束的资源池上的并行测试运行之间共享资源。
一个单独的服务跟踪资源的存在,因此假设发现(查询它们)很简单。
安装-e git-git+https://github.com/armmbed/resource-lock e r.git-egg=resource_locker `
<<<
<<
<
`` python
`一些资源方面的东西
devices=list_connect _连接的设备
R(*设备,需要=2,key_gen=attrgetter('id')
req2=R(P('this one thing')
获得锁(req1,req2,'other thing'):
打印(获得[0][0])第一个要求,第一个设备
打印(获得[0][1])第一个要求第二个设备
打印(获得[2][0][0])`其他东西`
替代
req1[1]ţ第二个设备
req2[0]`这一件事`
```
` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `锁厂资源锁导入锁
custom=redislockfactory(client=strictredis(db=7))
lock('a',lock\u factory=custom)
````
资源锁导入p
带锁(p('a',model='t1000'),reporter_class=reporter.redisreporter):
time.sleep(1)
reporter.query().all_tags(),['key','model']
reporter.query().all_values('model'),['t1000']
reporter.query().all_aspects('model','t1000')。…
{lock_acquire计数:1,
“锁定获取等待”:0.008001565933228,
“锁定释放计数”:1,
“锁定释放等待”:1.000413179397583,
“锁请求计数”:1}
```
```python
``python
from functools import partial
from redis import stricredis
from resource郦locker import reporter
client=stricredis(db=9)
custom郦reporter=部分(reporter.RedisReporter,client=client)
锁定(报告者类=自定义报告者)
```
p=30188&seqnum=7)
[同步锁定](http://www.informit.com/articles/article.aspx?p=30188&seqnum=6)
请一次一个!
[![Circleci](https://circleci.com/gh/armmbed/resource\u locker.svg?style=shield&circle token=992df378a72010c9b4ed32c14c1354cda9664d2)(https://circleci.com/gh/armmbed/resource\u locker)
[![覆盖范围](https://img.shields.io/badge/coverage-100%25 brightgreen.svg)(https://circleci.com/gh/armmbed/resource\u locker)
[![欢迎投稿](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat](https://github.com/armmbed/resource撸locker)
或类似的方法)。
资源被假定为可被打算使用它们的客户发现和筛选。
这减少了代表客户对资源进行分类和筛选的需要,与具有所有资源数据库的资源分配系统(通常只有资源
服务器执行发现)相比,
数据库n是的**客户端数量)
实际上,目的是在受约束的资源池上的并行测试运行之间共享资源。
一个单独的服务跟踪资源的存在,因此假设发现(查询它们)很简单。
安装-e git-git+https://github.com/armmbed/resource-lock e r.git-egg=resource_locker `
<<<
<<
<
`` python
`一些资源方面的东西
devices=list_connect _连接的设备
R(*设备,需要=2,key_gen=attrgetter('id')
req2=R(P('this one thing')
获得锁(req1,req2,'other thing'):
打印(获得[0][0])第一个要求,第一个设备
打印(获得[0][1])第一个要求第二个设备
打印(获得[2][0][0])`其他东西`
替代
req1[1]ţ第二个设备
req2[0]`这一件事`
```
` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `锁厂资源锁导入锁
custom=redislockfactory(client=strictredis(db=7))
lock('a',lock\u factory=custom)
````
资源锁导入p
带锁(p('a',model='t1000'),reporter_class=reporter.redisreporter):
time.sleep(1)
reporter.query().all_tags(),['key','model']
reporter.query().all_values('model'),['t1000']
reporter.query().all_aspects('model','t1000')。…
{lock_acquire计数:1,
“锁定获取等待”:0.008001565933228,
“锁定释放计数”:1,
“锁定释放等待”:1.000413179397583,
“锁请求计数”:1}
```
```python
``python
from functools import partial
from redis import stricredis
from resource郦locker import reporter
client=stricredis(db=9)
custom郦reporter=部分(reporter.RedisReporter,client=client)
锁定(报告者类=自定义报告者)
```
p=30188&seqnum=7)
[同步锁定](http://www.informit.com/articles/article.aspx?p=30188&seqnum=6)