Issue with Couchbase Python SDK (acouchbase) InternalSDKException and SystemError

Hello Couchbase community,

I’m encountering an issue while using the Couchbase Python SDK (specifically acouchbase) version 3.2.7 in my Flask application. The application uses asynchronous code and integrates with Couchbase as its database.

I’ve come across an error that I’m having trouble resolving. Below is the stack trace of the error:

Traceback (most recent call last):
File “D:\NX Env.venv\lib\site-packages\acouchbase\asyncio_iops.py”, line 96, in update_event
self.loop.remove_reader(event.fd)

SystemError: PyEval_EvalFrameEx returned a result with an error set

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

SystemError: <built-in method _connect of ACluster object at 0x000001AE6EFBBE40> returned a result with an error set

It seems that the issue is related to an InternalSDKException originating from the Couchbase SDK, specifically in the asynchronous part of the code. This is leading to a subsequent SystemError during the evaluation of frames.

I’ve reviewed my code and the Couchbase SDK integration, but I’m unable to identify the exact cause of this issue. I’m using the acouchbase version 3.2.7, and my application is built on Python 3.8.3.

Could someone provide insights into what might be causing this error and how I can go about resolving it? Are there any known compatibility issues between acouchbase 3.2.7 and certain versions of Couchbase or Python?

Any help or guidance would be greatly appreciated. Thank you in advance for your assistance!

Hi @achari.prashant – I have not come across this issue in particular, so without a way to reproduce the issue I don’t think I can provide guidance. Do you have a minimal example you can provide that reproduces the issue?

In terms of addressing the issue more quickly, would you be able to upgrade to the 4.x version of the SDK? The APIs should be the same, but you should gain an improvement in behavior (especially w.r.t. the asynchronous API). Ideally this is the path forward we can take since if there is an issue w/ the 3.x acouchbase API I do not think we will be able to make a change to the 3.x series of the SDK.

setting the eveent loop policy in windows reectified the issue.

import asyncio
import selectors

class MyPolicy(asyncio.DefaultEventLoopPolicy):
def new_event_loop(self):
selector = selectors.SelectSelector()
return asyncio.SelectorEventLoop(selector)

asyncio.set_event_loop_policy(MyPolicy())import asyncio

Hi @achari.prashant – Glad you found a solution. Out of curiosity, how are you obtaining the event loop? We provide an example in the 3.x branch on using the get_event_loop method the acouchbase API provides. That should setup the correct event loop for the API. Would be curious if that was not working or if that is the path you could take. See example here.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.