Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

TypeError: __await__() returned a coroutine #63

Closed
jwelch1324 opened this issue Sep 12, 2020 · 2 comments
Closed

TypeError: __await__() returned a coroutine #63

jwelch1324 opened this issue Sep 12, 2020 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@jwelch1324
Copy link

When attempting to run the Flask example on the main README I get the following error

/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/spotify/models/user.py:199: RuntimeWarning: coroutine 'WrappedUser.__await__' was never awaited
  return await cls.from_token(client, token, refresh_token)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/spotify/models/user.py:199: RuntimeWarning: coroutine 'User.from_token.<locals>.constructor' was never awaited
  return await cls.from_token(client, token, refresh_token)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[2020-09-11 19:39:28,645] ERROR in app: Exception on /spotify/callback [GET]
Traceback (most recent call last):
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "test.py", line 30, in spotify_callback
    SPOTIFY_USERS[key] = spotify.User.from_code(
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/spotify/sync/models.py", line 45, in wrapped
    return self.__client_thread__.run_coroutine_threadsafe(
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/spotify/sync/thread.py", line 48, in run_coroutine_threadsafe
    return future.result()
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/Users/user/miniconda3/envs/env22/lib/python3.8/site-packages/spotify/models/user.py", line 199, in from_code
    return await cls.from_token(client, token, refresh_token)
TypeError: __await__() returned a coroutine

I am running the following python environment:

Python 3.8.5
spotify 0.10.2
flask 1.1.2
@mental32 mental32 added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Sep 15, 2020
@michaeldcanady
Copy link

It seems that from_token is not async, I added that to the declaration. It fixed this issue but returns a Wrapper user object.

async def from_token(
        cls,
        client: "spotify.Client",
        token: Optional[str],
        refresh_token: Optional[str] = None,
    ) -> WrappedUser:

@bmeares
Copy link
Contributor

bmeares commented Jan 31, 2021

I opened (my first ever) PR #68 where I removed await from return await cls.from_token(client, token, refresh_token) in User.from_code. Now await spotify.User.from_code(...) seems to work for me in FastAPI and Flask.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants