HENNGE / aiodynamo

Asynchronous, fast, pythonic DynamoDB Client
https://aiodynamo.readthedocs.io/
Other
72 stars 21 forks source link

await table.exists() is stuck/hanging #176

Open ishaan-jaff opened 8 months ago

ishaan-jaff commented 8 months ago

Running this code hangs for me at await table.exists(), how can i debug this issue ? I can't see any logs

from aiohttp import ClientSession

from aiodynamo.client import Client
from aiodynamo.credentials import Credentials
from aiodynamo.expressions import F
from aiodynamo.http.aiohttp import AIOHTTP
from aiodynamo.models import Throughput, KeySchema, KeySpec, KeyType
from aiodynamo.http.httpx import HTTPX
from dotenv import load_dotenv
load_dotenv()

async def example():
    async with ClientSession() as session:
        credentials = await Credentials.auto().get_key(http=HTTPX(session))
        print(credentials)
        print(credentials.secret)
        print(credentials.id)
        print(credentials.token)
        client = Client(AIOHTTP(session), Credentials.auto(), "us-west-2")
        print(client.credentials)

        table = client.table("any-table")
        print("checking if table exists")
        does_table_exist = await table.exists()
        print("checked if exists=", does_table_exist)

        # Create table if it doesn't exist
        if not await table.exists():
            await table.create(
                Throughput(read=10, write=10),
                KeySchema(hash_key=KeySpec("key", KeyType.string)),
            )

        # Create or override an item
        await table.put_item({"key": "my-item", "value": 1})
        # Get an item
        item = await table.get_item({"key": "my-item"})
        print(item)
        # Update an item, if it exists.
        await table.update_item(
            {"key": "my-item"}, F("value").add(1), condition=F("key").exists()
        )
import asyncio

asyncio.run(example())
ishaan-jaff commented 8 months ago

I see this in my logs:

DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
DEBUG:aiodynamo:sending request Request(url=URL('https://dynamodb.us-west-2.amazonaws.com/'), body=b'{"TableName":"LiteLLM_VerificationToken"}')
DEBUG:aiodynamo:request failed
ishaan-jaff commented 8 months ago

caused by this:

Cannot connect to host dynamodb.us-west-2.amazonaws.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

@ojii can I get help with this error? have you seen it before ?

ojii commented 8 months ago

huh that's a new one.

what environment is this running in (local/ec2/ecs/...)?

if this is running on AWS, have you checked your security group that there's nothing in there blocking connections?

the fact that the error is CERTIFICATE_VERIFY_FAILED indicates that this isn't an issue with aiodynamo, but your environment and/or httpx.