[Django] #31626: Add asgi support to runserver

55 views
Skip to first unread message

Django

unread,
May 24, 2020, 3:14:27 PM5/24/20
to django-...@googlegroups.com
#31626: Add asgi support to runserver
-------------------------------------------+------------------------
Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 24, 2020, 3:18:58 PM5/24/20
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+--------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by Joshua Massover:

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>

Django

unread,
May 26, 2020, 6:36:57 AM5/26/20
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+--------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: closed
Component: Uncategorized | Version: 3.0
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Jun 3, 2020, 2:03:57 PM6/3/20
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+-------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: closed
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution: needsinfo
Keywords: runserver, asgi | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Jun 3, 2020, 2:05:34 PM6/3/20
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution:
Keywords: runserver, asgi | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Carlton Gibson):

* status: closed => new
* resolution: needsinfo =>


--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:4>

Django

unread,
Jun 29, 2020, 8:53:22 PM6/29/20
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution:
Keywords: runserver, asgi | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

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>

Django

unread,
Mar 7, 2023, 6:00:00 AM3/7/23
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution:
Keywords: runserver, asgi | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Mar 7, 2023, 1:49:03 PM3/7/23
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution:
Keywords: runserver, asgi | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

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>

Django

unread,
Mar 7, 2023, 1:49:41 PM3/7/23
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution:
Keywords: runserver, asgi | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

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>

Django

unread,
Mar 7, 2023, 1:51:46 PM3/7/23
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: closed

Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution: wontfix

Keywords: runserver, asgi | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* 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>

Django

unread,
Mar 7, 2023, 1:51:54 PM3/7/23
to django-...@googlegroups.com
#31626: Add asgi support to runserver
---------------------------------+--------------------------------------

Reporter: Joshua Massover | Owner: nobody
Type: New feature | Status: closed
Component: HTTP handling | Version: 3.0
Severity: Normal | Resolution: wontfix
Keywords: runserver, asgi | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Unreviewed


--
Ticket URL: <https://code.djangoproject.com/ticket/31626#comment:10>

Reply all
Reply to author
Forward
0 new messages