scarletcafe / jishaku

A debugging and testing cog for discord.py rewrite bots.
https://jishaku.readthedocs.io/en/latest/
MIT License
541 stars 181 forks source link

Can I put executor function on an async method? #137

Closed theAbdoSabbagh closed 2 years ago

theAbdoSabbagh commented 2 years ago

title

scarletcafe commented 2 years ago

The executor function helper is designed to allow 'heavy' (blocking) synchronous functions to be easily wrapped to be callable from an async context. This is supposed to be a shortcut for the traditional route of using run_in_executor yourself, since that requires some more long-form setup, especially if you need special things like kwargs.

Since the entire point of using an executor is to take things out of the event loop, I'm not sure why you'd want to be able to use the wrapper on an async function. If the function is async, you should just await it directly unless you have a really good reason not to do so.

scarletcafe commented 2 years ago

Assuming this issue is solved.