Skip to content

Consider mentioning Django's Async ORM Interface #1999

@johnthagen

Description

@johnthagen

Tutorial 3, section "Rewrite the consumer to be asynchronous" states:

Even if ChatConsumer did access Django models or other synchronous code it would still be possible to rewrite it as asynchronous. Utilities like asgiref.sync.sync_to_async and channels.db.database_sync_to_async can be used to call synchronous code from an asynchronous consumer. The performance gains however would be less than if it only used async-native libraries.

This feels like it was written before the Django async ORM interface. It might be worth somehow mentioning that in Django 4.1+, there is at least an async interface for the ORM. Otherwise, new users might get the feeling like that if they do anything with ORM Models, it will be synchronous anyway and might not realize they could pursue more async in a more natural way with channels and modern versions of Django.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions