Have been using acouchbase for all operations (including single and multi inserts, upserts and removal).
But the counter function fails and throws an exception.
result = await collection.counter("doc_id", delta=1)
TypeError: object AsyncResult can’t be used in ‘await’ expression
import asyncio
import time
import json
from couchbase.options import (ClusterOptions, ClusterTimeoutOptions, IncrementOptions, DeltaValue)
from acouchbase.cluster import Cluster
from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import QueryOptions
async def main():
print(f"started at {time.strftime('%X')}")
cluster = Cluster('couchbase://127.0.0.1', ClusterOptions(PasswordAuthenticator('Administrator', 'password')))
cb = cluster.bucket('my_bucket')
collection = cb.default_collection()
result2 = await collection.binary().increment("doc_id", IncrementOptions(delta=DeltaValue(5)))
print(f"finished at {time.strftime('%X')} {result2}")
asyncio.run(main())
started at 09:45:47
finished at 09:45:47 CounterResult:{'cas': 1685119547093090304, 'mutation_token': <pycbc_core.mutation_token object at 0x1065f1bd0>, 'content': 80}
Btw - you would likely benefit from using a newer version of the Python SDK.
I tried something similar but it throws an exception
import time
from couchbase.collection import (IncrementOptions, DeltaValue)
from acouchbase.cluster import Cluster
from couchbase.cluster import ClusterOptions, PasswordAuthenticator
print(f"started at {time.strftime('%X')}")
cluster = Cluster('couchbase://127.0.0.1', options=ClusterOptions(PasswordAuthenticator('Administrator', 'password')))
cb = cluster.bucket('my_bucket')
collection = cb.default_collection()
result2 = await collection.binary().increment("doc_id", IncrementOptions(delta=DeltaValue(5)))
print(f"finished at {time.strftime('%X')} {result2}")
couchbase.exceptions.ClientTemporaryFailException: <RC=0x3F8[LCB_ERR_NO_CONFIGURATION (1016)], There was a problem scheduling your request, or determining the appropriate server or vBucket for the key(s) requested. This may also be a bug in the SDK if there are no network issues, C Source=(src/counter.c,118)>