# How can async support dispatch between sync and async variants of the same code?

**URL:** <https://discuss.python.org/t/how-can-async-support-dispatch-between-sync-and-async-variants-of-the-same-code/15014>\
**Category:** Async-SIG\
**Created:** [April 12, 2022, 6:00pm UTC](https://discuss.python.org/t/how-can-async-support-dispatch-between-sync-and-async-variants-of-the-same-code/15014 "2022-04-12T18:00:17Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/guido/32/21_2.png) [@guido](https://discuss.python.org/u/guido)\
**Post date:** [April 13, 2022, 4:17am UTC](https://discuss.python.org/t/how-can-async-support-dispatch-between-sync-and-async-variants-of-the-same-code/15014/5 "2022-04-13T04:17:50Z")

</div>

I think the reason this hasn’t been solved in its full generality is that there’s no perfect solution. Adding another keyword to the language (`maybe_async`) just isn’t in the cards.

Library and framework authors are usually best off having an opinionated convention aided by a decorator or metaclass fitted to the needs of the library or framework. (I believe I’ve seen a metaclass that looked for methods named `async_spam` and added a synchronous version named `spam` for each such.)

---

_[View the full topic](https://discuss.python.org/t/how-can-async-support-dispatch-between-sync-and-async-variants-of-the-same-code/15014)._
