Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-1056

MutateIn broken for all asyncio, twisted



    • Bug
    • Resolution: Fixed
    • Major
    • 3.0.7
    • 3.0.5
    • library
    • None
    • 1
    • SDK48: FTS Score/Incl, Docs.


      From investigation of CBSE-9011, if you are using Asyncio, and do something like:

      async def mutate_in():
          coll = bucket.default_collection()
          res = coll.mutate_in("foo", {SD.upsert("other", "path"),})
          return await res

      you will see:

      Traceback (most recent call last):
        File "asiominimal.py", line 31, in <module>
          rv2 = loop.run_until_complete(mutate_in())
        File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
          return future.result()
        File "asiominimal.py", line 21, in mutate_in
          res = coll.mutate_in("foo", {SD.upsert("other", "path"),})
        File "/Users/davidkelly/projects/gerrit/couchbase-python-client/couchbase/collection.py", line 258, in wrapped
          return func(self, *args, **kwargs)
        File "/Users/davidkelly/projects/gerrit/couchbase-python-client/acouchbase/cluster.py", line 45, in ret
          rv.set_callbacks(on_ok, on_err)
      AttributeError: 'MutateInResult' object has no attribute 'set_callbacks'

      Seems that there is no AsyncMutateInResult, or mechanism to map it similar to AsyncMutationResult. One would think that just changing annotation of collection.mutate_in to be @mutate_result_and_inject instead of @inject_scope_and_collection. would maybe do it, but that insists on a MutationResult or AsyncMutationResult.

      Of course, same issue for twisted. If you do somewhat the same thing, you get:

      	--- <exception caught here> ---
      	  File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
      	    current.result = callback(current.result, *args, **kw)
      	  File "/Users/davidkelly/projects/gerrit/couchbase-python-client/txcouchbase/cluster.py", line 357, in <lambda>
      	    qop.addCallback(lambda x: f(meth, *args, **kwargs))
      	  File "/Users/davidkelly/projects/gerrit/couchbase-python-client/txcouchbase/cluster.py", line 371, in _wrap
      	    return self.defer(opres)
      	  File "/Users/davidkelly/projects/gerrit/couchbase-python-client/txcouchbase/cluster.py", line 279, in defer
      	    opres.set_callbacks(d.callback, _on_err)
      	builtins.AttributeError: 'MutateInResult' object has no attribute 'set_callbacks'

      So lets get this correct. Then, perhaps as a second issue, lets sweep through asyncio and twisted apis and insure the very basics (say, every method in collections) are tested. At a minimum.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            david.kelly David Kelly (Inactive)
            david.kelly David Kelly (Inactive)
            0 Vote for this issue
            3 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes