Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coroutine '<method that is cached>' was never awaited #59

Open
Pegietix opened this issue Aug 14, 2021 · 1 comment
Open

coroutine '<method that is cached>' was never awaited #59

Pegietix opened this issue Aug 14, 2021 · 1 comment

Comments

@Pegietix
Copy link

Pegietix commented Aug 14, 2021

Hey,
I am using your library and everything works fine for "normal" requests.

Problem arises, when I want to call cached method from within the same service.

My route:

@router.get('/get-fiat-currency-choices')
@cache()
def get_fiat_currency_choices():
    response_data = requests.get(f'{CURRENCY_EXCHANGE_API_URL}/currencies').json()

    choices = []
    for symbol, name in response_data.items():
        choices.append(
            {
                'symbol': symbol,
                'name': name,
            }
        )

    return choices

I am trying to call it with:

    @validator('currency')
    def validate_currency(cls, val):
        allowed_currencies = [currency['symbol'] for currency in get_fiat_currency_choices()]
        if val not in allowed_currencies:
            raise ValidationError('Currency is not supported.')
        return val

Error I am getting:

RuntimeWarning: coroutine 'get_fiat_currency_choices' was never awaited
2021-08-14T17:24:37.540579531Z   allowed_currencies = [currency['symbol'] for currency in get_fiat_currency_choices()]
2021-08-14T17:24:37.540585575Z RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Would appreciate any help, thanks!

P.S. The same thing occurs when I am using similar library 'fastapi-cache2' (https://github.com/long2ice/fastapi-cache)

@stratosgear
Copy link

Weird! I am getting the same error. Did you ever figure this one out...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants