[Django] #32092: Add an async db backend: asyncpg

23 views
Skip to first unread message

Django

unread,
Oct 8, 2020, 4:12:12 PM10/8/20
to django-...@googlegroups.com
#32092: Add an async db backend: asyncpg
-------------------------------------+-------------------------------------
Reporter: Andrew | Owner: nobody
Chen Wang |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords: database
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This ticket wishes to add an asynchronous DB backend, namely using
[https://github.com/MagicStack/asyncpg asyncpg].

I've recently finished porting
[https://code.djangoproject.com/ticket/32076 Django's cache to use async
methods] in an async context. I'm continuing along my opinion that we need
to have the layer of the cake down, i.e. the cache and the db backends,
before the rest of the async porting of Django can continue. Thus, I'd
like to begin getting an async database backend as well using asyncpg for
a future async Django ORM along with async template loading (since
psycopg3 is not complete).

I don't have much experience with the ORM itself, but I'd like to get the
work started. One of the reasons this hasn't been started grandly is
mentioned in DEP 9:

> A lot of this stems from the fact that the underlying database drivers
are synchronous

[https://github.com/django/deps/blob/master/accepted/0009-async.rst#the-
orm from here] and because Andrew, not me, is pretty busy lately. I think
I can alleviate some of the workload by implementing this backend as a way
to get started testing an async ORM.

--
Ticket URL: <https://code.djangoproject.com/ticket/32092>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 8, 2020, 7:28:30 PM10/8/20
to django-...@googlegroups.com
#32092: Add an async db backend: asyncpg
-------------------------------------+-------------------------------------
Reporter: Andrew Chen Wang | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: database | 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 Andrew Chen Wang:

Old description:

> This ticket wishes to add an asynchronous DB backend, namely using
> [https://github.com/MagicStack/asyncpg asyncpg].
>
> I've recently finished porting
> [https://code.djangoproject.com/ticket/32076 Django's cache to use async
> methods] in an async context. I'm continuing along my opinion that we
> need to have the layer of the cake down, i.e. the cache and the db
> backends, before the rest of the async porting of Django can continue.
> Thus, I'd like to begin getting an async database backend as well using
> asyncpg for a future async Django ORM along with async template loading
> (since psycopg3 is not complete).
>
> I don't have much experience with the ORM itself, but I'd like to get the
> work started. One of the reasons this hasn't been started grandly is
> mentioned in DEP 9:
>
> > A lot of this stems from the fact that the underlying database drivers
> are synchronous
>
> [https://github.com/django/deps/blob/master/accepted/0009-async.rst#the-
> orm from here] and because Andrew, not me, is pretty busy lately. I think
> I can alleviate some of the workload by implementing this backend as a
> way to get started testing an async ORM.

New description:

This ticket wishes to add an asynchronous DB backend, namely using
[https://github.com/MagicStack/asyncpg asyncpg].

I don't have much experience with the ORM itself, but I'd like to get the


work started. One of the reasons this hasn't been started grandly is
mentioned in DEP 9:

> A lot of this stems from the fact that the underlying database drivers
are synchronous

One thing that must take place before this ticket starts any code is the
design decision. Don't know how to cc people, but I'd like to know what
the design decision would be? Unlike `cache.get_async`with that `_async`
suffix, I feel like BaseDatabaseWrapper should just be duplicated into an
AsyncBaseDatabaseWrapper? It wouldn't be DRY, so I'd love to know some
thoughts!

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32092#comment:1>

Django

unread,
Oct 9, 2020, 12:23:21 AM10/9/20
to django-...@googlegroups.com
#32092: Add an async db backend: asyncpg
-------------------------------------+-------------------------------------
Reporter: Andrew Chen Wang | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: database | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

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


Comment:

Andrew is already working on the async ORM and as far as I'm aware an
async backend is not the part of it. It can be the last step that is not
even mentioned in the accepted DEP 9. Please check
[https://forum.djangoproject.com/c/internals/async/8 async topics] and
start a discussion on DevelopersMailingList before you will create more
async-related tickets.

--
Ticket URL: <https://code.djangoproject.com/ticket/32092#comment:2>

Django

unread,
Oct 10, 2020, 6:10:10 AM10/10/20
to django-...@googlegroups.com
#32092: Add an async db backend: asyncpg
-------------------------------------+-------------------------------------
Reporter: Andrew Chen Wang | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: database | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by Carlton Gibson):

Hey Andrew.

As Mariusz says, [https://forum.djangoproject.com/c/internals/async/8 the
Forum is probably the best place] to begin discussing these things. The
long answer is Yes to all of these things, but the issue tracker here
isn't the place to begin the discussion — we're too far away from a
concrete plan so everything is either wontfix or needsinfo, whichever way
you cut it.

If you work with Andrew on the forum to work out the path forward, that
would be amazing. Then probably via django-developers, and here, maybe wit
a DEP depending on size.

I hope that makes sense! Thanks for your input!

--
Ticket URL: <https://code.djangoproject.com/ticket/32092#comment:3>

Reply all
Reply to author
Forward
0 new messages