我有以下代码用于连接到现有的Couchbase存储桶并检索文档。如何为couchbase连接强制自定义超时值(以秒为单位)?
import couchbase
from couchbase.bucket import Bucket
import couchbase.exceptions
cb_nodes="123.456.7.89"
cb_bucket = "default"
def fetch_doc(self, key):
try:
cb = Bucket('couchbase://' + cb_nodes + '/' + cb_bucket)
doc = cb.get(key)
return doc
except couchbase.exceptions.NotFoundError as e:
print("Key Not Found")
except couchbase.exceptions.TimeoutError as e:
print("Couchbase connection timed out")
except couchbase.exceptions.CouchbaseNetworkError as e:
print("Couchbase Connection failed")我正在使用Python 3,Couchbase 4.1和Python SDK 2.1 for Couchbase。
我找到了这个- https://developer.couchbase.com/documentation/server/4.1/developer-guide/error-handling.html#concept_ybj_tqs_zs__devguide-transient-errors,但它并没有真正说明我应该如何或在哪里设置超时值。
这方面的任何帮助都是非常感谢的。
谢谢!
发布于 2017-05-08 12:23:15
current Client Settings section of the Couchbase Documentation中涵盖了包括超时在内的各种设置。你所指的链接有点老了。
https://stackoverflow.com/questions/43828063
复制相似问题