It would be great to add an `asgi` flag such that runserver will "just
work" with ASGI. eg.
`./manage.py runserver --asgi`
The 4 options I've thought of are the following:
1. Update runserver in django in a way that keeps the daphne import
optional.
2. Add daphne as a dependency to django and update runserver.
3. Maintain a separate django app that holds the command that integrates
daphne with runserver. Reference the app in asgi section of the django
documentation.
4. Add the commands to the daphne repository, perhaps allowing us to add
daphne as an installed app so the command is discovered, and reference
this in the asgi section of the django documentation.
I have an [https://github.com/django/django/pull/12969 initial pr] for
(1). This code depends on #31594.
--
Ticket URL: <https://code.djangoproject.com/ticket/31626>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> Conversation about this ticket can be found on the
> [https://forum.djangoproject.com/t/adding-asgi-support-to-runserver/2446
> django forum]
>
> It would be great to add an `asgi` flag such that runserver will "just
> work" with ASGI. eg.
>
> `./manage.py runserver --asgi`
>
> The 4 options I've thought of are the following:
>
> 1. Update runserver in django in a way that keeps the daphne import
> optional.
> 2. Add daphne as a dependency to django and update runserver.
> 3. Maintain a separate django app that holds the command that integrates
> daphne with runserver. Reference the app in asgi section of the django
> documentation.
> 4. Add the commands to the daphne repository, perhaps allowing us to add
> daphne as an installed app so the command is discovered, and reference
> this in the asgi section of the django documentation.
>
> I have an [https://github.com/django/django/pull/12969 initial pr] for
> (1). This code depends on #31594.
New description:
Previous conversation about this ticket can be found on the
[https://forum.djangoproject.com/t/adding-asgi-support-to-runserver/2446
django forum]
It would be great to add an `asgi` flag such that runserver will "just
work" with ASGI. eg.
`./manage.py runserver --asgi`
The 4 options I've thought of are the following:
1. Update runserver in django in a way that keeps the daphne import
optional.
2. Add daphne as a dependency to django and update runserver.
3. Maintain a separate django app that holds the command that integrates
daphne with runserver. Reference the app in asgi section of the django
documentation.
4. Add the commands to the daphne repository, perhaps allowing us to add
daphne as an installed app so the command is discovered, and reference
this in the asgi section of the django documentation.
I have an [https://github.com/django/django/pull/12969 initial pr] for
(1). This code depends on #31594.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:1>
* status: new => closed
* resolution: => needsinfo
Comment:
I'm going to momentarily close this as `needsinfo` — let's continue the
discussion on the forum thread: we can re-open if it's agreed to bundle
this.
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:2>
* keywords: => runserver, asgi
* component: Uncategorized => HTTP handling
* stage: Unreviewed => Accepted
Comment:
OK, let's accept this as a new feature.
The suggestion in the forum thread is to detect if Daphne or uvicorn or
... is installed and then use that.
In the draft PR looks like importing Daphne in a `try` block, which I´m
not sure about at all.
Is there a way we can detect the asgi server without hard-coding imports?
I'd imagined a server based off of Python's `http.server`, as we have for
WSGI, either in Django or `asigref` as appropriate.
In the meantime, 3.1 could probably do with some docs, saying to install
channels (to use it's runserver) or uvicorn (which has a `--reload`
option).
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:3>
* status: closed => new
* resolution: needsinfo =>
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:4>
Comment (by sethmlarson):
Hey! So I recently had a user hit this issue when using the recently added
async support to the Elasticsearch client library.
See here: https://github.com/elastic/elasticsearch-py/issues/1303
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:5>
* has_patch: 0 => 1
Comment:
I've created a PR to doc that Daphne provided a `runserver`
implementation. ([https://github.com/django/django/pull/16634 PR])
You enable it like this:
{{{
INSTALLED_APPS = [
"daphne",
...
]
}}}
Other packages could do similar easily enough.
I'm not 100% convinced it's worth extra code to scan installed
dependencies, and check it they provide a `runsever`.
It could be that we close this as `wontfix`. 🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:6>
Comment (by GitHub <noreply@…>):
In [changeset:"279e611c017b5fcc055263e760de1495a9098ede" 279e611]:
{{{
#!CommitTicketReference repository=""
revision="279e611c017b5fcc055263e760de1495a9098ede"
Refs #31626 -- Noted that Daphne provides a runserver command.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d89d517f90851654afb1073174b3c75d08452f3c" d89d517]:
{{{
#!CommitTicketReference repository=""
revision="d89d517f90851654afb1073174b3c75d08452f3c"
[4.2.x] Refs #31626 -- Noted that Daphne provides a runserver command.
Backport of 279e611c017b5fcc055263e760de1495a9098ede from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:8>
* status: new => closed
* resolution: => wontfix
Comment:
> It could be that we close this as `wontfix`. 🤔
Let's close it.
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:9>
* stage: Accepted => Unreviewed
--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:10>