Coder Social home page Coder Social logo

Comments (4)

mental32 avatar mental32 commented on June 8, 2024

Thank you for reporting this, I'm currently Investigating.

As far as I can tell aiohttp is experiencing loop confusion when attempting to invoke the request.

I haven't used hypercorn but from what I've gathered its an asynchronous gunicorn? If this is the case then this can explain the loop confusion.

Also I've noticed that a potential fix could be if you simply created your spotify.Client instance inside a coroutine and that would resolve the confusion.

from spotify.py.

sshamaiengar avatar sshamaiengar commented on June 8, 2024

Yes, hypercorn is async gunicorn.

If this is the case then this can explain the loop confusion.

I don't know much about how event loops work so would you mind explaining this a bit more?

I am not sure how/where to create the spotify.Client inside a coroutine. Currently, it is created within my create_app factory function, which is synchronous and is what is passed to hypercorn to start a worker.

from spotify.py.

mental32 avatar mental32 commented on June 8, 2024

I don't know much about how event loops work so would you mind explaining this a bit more?

The aiohttp session when created outside of a running event loop doesn't know which one it should attach itself to, so when one does start to perform operations over the session, the session's internals will appropriately detect something funky going on and panic, this can explain the RuntimeError you were catching.

Off the top of my head a solution could be assigning the spotify client attribute on your quart server instance and set it to None. Then setup some sort of before_request handler and there you perform the check and construct the client when app.spotify is None

from spotify.py.

sshamaiengar avatar sshamaiengar commented on June 8, 2024

Using the before_request handler to initialize the Spotify client worked for me. Thanks for your help!

from spotify.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.