Hi all,
While working on async related tickets (eg #34717, and more recently #34757) I noticed code duplication between sync and async version of same functions:
some examples: (no personal offense ❤️)
As I'm working on #34757, and following this pattern, there would be some duplication of the
TestClient._handle_redirects method to support the async case.
I'm kind of ok when duplicating a 3 lines function. Not that much with a 50 lines function. that could easily become a maintenance burden.
I've read DEP-009 a few times and the plan at the time was (quoted from the "Technical Overview")
Each feature will go through three stages of implementation:
- Sync-only (where it is today)
- Sync-native, with an async wrapper
- Async-native, with a sync wrapper
I was wondering:
1- why do we see almost no sync wrapper (async_to_sync) in django's code base ? Is that a best practice ?
2- what do you think about code duplication of async function ? (please point me to existing threads if the discussion already occurred) What is Ok / What is not ok ? Is there some cleanup to be done ?
Cheers,
- Olivier Tabone