python-consul,,import con
python-consul,,import con
import consul
c = consul.Consul(host="192.168.111.111")
c.kv.put("key","value")
a = c.kv.get("key")
print a
(‘107‘, {u‘LockIndex‘: 0, u‘ModifyIndex‘: 107, u‘Value‘: ‘value‘, u‘Flags‘: 0, u‘Key‘: u‘key‘, u‘CreateIndex‘: 107})
a = c.session.create(name="mhc",behavior=‘release‘,ttl=25)
c.kv.put("key111", "v2222", acquire=a)
b = c.kv.get("key111")[1]
print b
{u‘LockIndex‘: 1, u‘ModifyIndex‘: 332, u‘Value‘: ‘v2222‘, u‘Session‘: u‘63d76352-f2ee-8cf0-8c01-b91581d22c1a‘, u‘Flags‘: 0, u‘Key‘: u‘key111‘, u‘CreateIndex‘: 332}
a = c.session.create(name="mhc",behavior=‘release‘,ttl=25)
c.kv.put("key111", "v2222", acquire=a)
time.sleep(2)
print c.kv.put("key111", "done", release=a)
b = c.kv.get("key111")[1]
print b
True
{u‘LockIndex‘: 3, u‘ModifyIndex‘: 368, u‘Value‘: ‘done‘, u‘Flags‘: 0, u‘Key‘: u‘key111‘, u‘CreateIndex‘: 332}
python-consul
相关内容
- python之IP地址或IP段处理模块-ipaddr,,python处理IP
- 自动化运维Python系列之ForeignKey、relationship联表查询,
- python内置函数1-basestring(),,Help on cl
- python第一课笔记,,Python 是什么
- "#!/usr/bin/python: No such file or director"引发的
- Python3小工具——暴力破解ssh,,一、工具说明利用px
- Python模块学习笔记— —hashlib,,hashlib是涉及
- Python数据可视化——散点图,多数据散点图怎么做,PS
- python3.5.2安装pip管理工具,python3pip安装,前言: 如果
- python轻量级ORM---peewee,,peewee是一个轻
评论关闭