Coder Social home page Coder Social logo

Comments (6)

mateokurti avatar mateokurti commented on August 15, 2024 2

Hi @em1208! I was looking for different possibilities to make async views on DRF, and run over your comment here. I'm trying to understand it. Why is there no need to change the server to Uvicorn? Shouldn't the app run with ASGI in order to support asynchronous code?

from adrf.

em1208 avatar em1208 commented on August 15, 2024

Hi @gschurck, apologies for the delay in the reply, I just noticed the open issue. You can mix and match sync and async endpoints, as long as the version of Django you are using is supported and adrf is installed correctly, and there is no need to change your server to Uvicorn for async support, I believe, but you can try different configurations and report here if you want. I have not made any performance/configuration comparison yet, but that's something in my mind that I would like to do when I have time. I hope this helps!

from adrf.

em1208 avatar em1208 commented on August 15, 2024

Hi @mateokurti, I believe you are right, the app should run with ASGI to support asynchronous code, Uvicorn is one of the available options.

from adrf.

mateokurti avatar mateokurti commented on August 15, 2024

Since this topic is related to my question, I'm just asking it here. @gschurck did you manage to optimize those long API calls? In my case, I made one endpoint async as it takes ~10 seconds to be finished. However, my other sync endpoints stay blocked until the request on the async endpoint is finished.
Note that I'm running the app with Daphne ASGI, so it only has 1 worker in contrast with uvicorn which can be run with multiple workers. It just doesn't make sense to me why an async view should be a blocker for others. What am I missing?

from adrf.

gschurck avatar gschurck commented on August 15, 2024

I didn't really find for now, I am afraid that all the endpoints have to be async to be handled concurrently ? But not sure.

from adrf.

em1208 avatar em1208 commented on August 15, 2024

PR #19 has been merged which add support for mixing synchronous and asynchronous handlers.

from adrf.

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.