-
-
Notifications
You must be signed in to change notification settings - Fork 817
Description
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 Model
s, 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.