我有以下代码来连接到现有的Couchbase bucket并检索文档。如何为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")
我正在为Couchbase使用python3、Couchbase 4.1和pythonsdk2.1。在
我找到了这个-https://developer.couchbase.com/documentation/server/4.1/developer-guide/error-handling.html#concept_ybj_tqs_zs__devguide-transient-errors,但它并没有真正说明我应该如何或在哪里设置超时值。在
如有任何帮助,我们将不胜感激。在
谢谢!在
在current Client Settings section of the Couchbase Documentation中介绍了包括超时在内的各种设置。你所指的链接有点老了。在
相关问题 更多 >
编程相关推荐