This is my python program:
import time
from couchbase.cluster import Cluster
from couchbase.cluster import PasswordAuthenticator
def writehandler(event, context):
cluster = Cluster('couchbase://h1,h2')
authenticator = PasswordAuthenticator('abc', 'abc')
cluster.authenticate(authenticator)
cb = cluster.open_bucket('firstbucket')
a = 1
start_time = time.time()
list1 ={}
while a <= 50000:
list1[str('doc_id_' + str(a))]={'airlines': a}
a = a + 1
# print(list1)
cb.upsert_multi(list1)
print("Write time = %s seconds " % (time.time() - start_time))
def readhandler(event, context):
cluster = Cluster('couchbase://h1,h2')
authenticator = PasswordAuthenticator('abc', 'abc')
cluster.authenticate(authenticator)
cb = cluster.open_bucket('firstbucket')
a = 1
start_time = time.time()
list1 =[]
while a <= 50000:
list1.append(str('doc_id_' + str(a)))
a = a + 1
cb.get_multi(list1)
print("Read time = %s seconds " % (time.time() - start_time))
if __name__ == '__main__':
writehandler(None, None)
readhandler(None,None)
It is showing following error.
Traceback (most recent call last):
File âmultiupsert_couchbase.pyâ, line 38, in
writehandler(None, None)
File âmultiupsert_couchbase.pyâ, line 18, in writehandler
cb.upsert_multi(list1)
File â/usr/local/lib/python3.5/dist-packages/couchbase/bucket.pyâ, line 1143, in upsert_multi
replicate_to=replicate_to)
couchbase.exceptions._TimeoutError_0x17 (generated, catch TimeoutError): <Key=âdoc_id_29901â, RC=0x17[Client-Side timeout exceeded for operation. Inspect network conditions or increase the timeout], Operational Error, Results=50000, C Source=(src/multiresult.c,316)>
main error is timeout error.