DEP Draft/Request For Shepherd: Unasyncify Codegen

Two points:

  • For codegen, I have split out the codegen experiment into its own package (as django-unasyncify). I am going to try and see if I can get any bites in third party apps that might want to try it, but this might be a bit of a failed experiment.

  • I have been looking at async_to_sync (see here), and generally speaking seeing costs that are under a millisecond (often much lower!). If the cost/benefit matrix is acceptable, there might be a “straightforward” answer here of leaning onto async_to_sync to offer one canonical async implementation and a sync fallback.

    But I believe that for sync database connections we would need a sync_to_async operation on the other end to balance things out, and that would be costly. That requirement is not immovable, it might be worth looking at replacing async_unsafe usage inside of DB connection APIs with a context-level lock or something. Tricky though, and I don’t like paying a potential correctness cost for this.

3 Likes