Flask-Discord icon indicating copy to clipboard operation
Flask-Discord copied to clipboard

Flask[async] compatibility

Open tdev-be opened this issue 1 year ago • 2 comments

use a coroutine if we are in async mode

tdev-be avatar Mar 20 '23 13:03 tdev-be

@tdev-be Thanks, this code works well. Could you make a repo with this already merged? I want to install it that way!

Space-Banane avatar Apr 12 '23 18:04 Space-Banane

Flask mentions here https://flask.palletsprojects.com/en/2.0.x/async-await/#extensions to use the ensure_sync function for extensions, like this:

def extension(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        ...  # Extension logic
        return current_app.ensure_sync(func)(*args, **kwargs)

    return wrapper

Havent testes it yet, but Im sure it works. I guess this should be used instead, there might be a good reason to not just await the view.

Guddi8 avatar Apr 14 '23 07:04 Guddi8