本文整理汇总了Python中couchdb.Server.tasks方法的典型用法代码示例。如果您正苦于以下问题:Python Server.tasks方法的具体用法?Python Server.tasks怎么用?Python Server.tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类couchdb.Server
的用法示例。
在下文中一共展示了Server.tasks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_replication_progress
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import tasks [as 别名]
def get_replication_progress(name):
'''
Get the progress of all continuous replications
'''
server = Server('http://localhost:5984/')
tasks = server.tasks()
i = 0
for task in tasks:
if i == 0:
if task.get('continuous'):
print "Continuous r={}, w={}, p={}%".format(task.get('docs_read'), task.get('docs_written'), task.get('progress'))
else:
print "Initialize r={}, w={}, p={}%".format(task.get('docs_read'), task.get('docs_written'), task.get('progress'))
i = i + 1
return 0
示例2: kill_running_replications
# 需要导入模块: from couchdb import Server [as 别名]
# 或者: from couchdb.Server import tasks [as 别名]
def kill_running_replications():
'''
Kill running replications in CouchDB (based on active tasks info).
Useful when a replication is in Zombie mode.
'''
server = Server('http://localhost:5984/')
for task in server.tasks():
data = {
"replication_id": task["replication_id"],
"cancel": True
}
headers = {'content-type': 'application/json'}
response = requests.post('http://localhost:5984/_replicate',
json.dumps(data), headers=headers)
if response.status_code == 200:
print 'Replication %s stopped.' % data['replication_id']
else:
print 'Replication %s was not stopped.' % data['replication_id']