Giter Site home page Giter Site logo

Auto-reload on code change about daphne HOT 19 CLOSED

django avatar django commented on May 22, 2024
Auto-reload on code change

from daphne.

Comments (19)

kiruh avatar kiruh commented on May 22, 2024 10

What is the current preferred way of auto reloading during development?

from daphne.

wolph avatar wolph commented on May 22, 2024 7

There are several reasons:

  1. Runserver is very limited, as soon as you have a more demanding web application (for example, one that requires parallel requests) it's not suitable anymore
  2. To reduce complexity and to make sure everything works similarly on production and development I run gunicorn on both with a single ansible deploy configuration. The only difference is that development has DEBUG enabled.

I agree with your statement that runserver = development but I disagree with runworker = production. While runworker can be used in production it can be used in development as well similarly to how gunicorn and celery can be used both in production and in development environments.

Luckily your environment is simple enough not to require anything outside the scope of runserver but that isn't to say everyone has that luxury.

from daphne.

wolph avatar wolph commented on May 22, 2024 4

@wolph OK, thanks... — not quite sure how helpful that's meant to be. Uvicorn is great. Glad you're having fun with that.

I understand it's not nice to hear but I could have implemented this years ago when Daphne was the only solution. Apparently there are alternative asgi servers these days which I wasn't aware of when I commented earlier.

So while it's perhaps not useful for you, it's useful for others that are faced with this problem. At the very least until this feature is implemented.

If you have a compelling reason to prefer Daphne over some of the other servers, please let me know. I couldn't immediately see any benefit but I'm not invested in any of the solutions so I'm open to suggestions and might even implement this feature if there is a point to it.

from daphne.

nathando avatar nathando commented on May 22, 2024 3

Hi guys, is this still an open issue as of now ?

from daphne.

wolph avatar wolph commented on May 22, 2024 1

A nice alternative for Daphne that does support reloading is Uvicorn btw: https://www.uvicorn.org/

from daphne.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

It would be nice for sure, but it's tricky to get right; the runserver implementation uses the Django auto-reload code which is a) already existing and tested and b) basically unchanged since 2007

Thus, re-implementing it is not the easiest. But, it would be nice, so I'll leave this open in the hope we get to it in the future.

from daphne.

wolph avatar wolph commented on May 22, 2024

True. The implementation should definitely borrow from one of the other
frameworks to reduce errors. For the time being I'll work around the
problem.

On a different note, is there a way to get Daphne running with nginx as a
proxy? I'm just starting with channels so it might be the rest of the code
but I can't seem to get a working response yet.
On May 5, 2016 02:23, "Andrew Godwin" [email protected] wrote:

It would be nice for sure, but it's tricky to get right; the runserver
implementation uses the Django auto-reload code which is a) already
existing and tested and b) basically unchanged since 2007

Thus, re-implementing it is not the easiest. But, it would be nice, so
I'll leave this open in the hope we get to it in the future.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#9 (comment)

from daphne.

hawkowl avatar hawkowl commented on May 22, 2024

Twisted has an issue with this because it needs to have the main thread/other reasons, see http://webcache.googleusercontent.com/search?q=cache:1yO9OJVnqVcJ:blog.elsdoerfer.name/2010/03/09/twisted-twistd-autoreload/+&cd=2&hl=en&ct=clnk&gl=us&client=firefox-b-ab for some details about how this works.

from daphne.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

@hawkowl Autoreload is actually enabled with runserver under a subthread; it has to have its signal handling turned off though, as that's the part of Twisted that seemed to want main thread access.

from daphne.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

It has been pointed out to me that autoreload outside the context of runserver makes no sense as Daphne does not actually host any user code, so closing this as WONTFIX.

from daphne.

wolph avatar wolph commented on May 22, 2024

You import the channel layer, do you not? If so, than please clarify why auto reloading would make no sense?

from daphne.

globophobe avatar globophobe commented on May 22, 2024

Why would you possibly need to auto reload outside of runserver? runserver = development, runworker = production. Personally, I was super happy to realize that thanks to channels I can now easily debug websockets.

As, for Nginx: http://nginx.org/en/docs/http/websocket.html

from daphne.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

I might agree with adding autoreload to runworker as an off-by-default option, but adding it to Daphne makes no sense, as the only thing you would need to reload for was if your CHANNEL_LAYER settings changed. You can run Daphne without even importing Django or your project at all if you set up a channel layer separately.

from daphne.

kmkmjhyiiiu avatar kmkmjhyiiiu commented on May 22, 2024

2020 30 June still not any updates?

from daphne.

carltongibson avatar carltongibson commented on May 22, 2024

This issue was closed as wontfix in 2016. Unless there's some case for re-opening there will not be any updates.

from daphne.

wolph avatar wolph commented on May 22, 2024

@carltongibson the original case for this is still valid and @andrewgodwin never responded to why it would make no sense to implement

from daphne.

carltongibson avatar carltongibson commented on May 22, 2024

If you want to do a proof of concept, using say watchgod like uvicorn, I’m happy to have a look at it!

from daphne.

carltongibson avatar carltongibson commented on May 22, 2024

@wolph OK, thanks... — not quite sure how helpful that's meant to be. Uvicorn is great. Glad you're having fun with that.

from daphne.

bartonip avatar bartonip commented on May 22, 2024

@kiruh I switched to Uvicorn as recommended by @wolph.

from daphne.

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.