Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coroutine 'SessionProxy.send_custom_message' Was Never Awaited #8

Open
mhanf opened this issue Sep 24, 2024 · 1 comment · May be fixed by #10
Open

Coroutine 'SessionProxy.send_custom_message' Was Never Awaited #8

mhanf opened this issue Sep 24, 2024 · 1 comment · May be fixed by #10

Comments

@mhanf
Copy link

mhanf commented Sep 24, 2024

Hello shiny_validate team
I am working on a Shiny Python application that uses sequently the enable() and disable() methods of an InputValidator object.
When I call the disable() method after the enable() one, I consistently encounter the following error:

C:\...\Python\Python311\Lib\site-packages\shiny_validate\validator.py:115: RuntimeWarning: coroutine 'SessionProxy.send_custom_message' was never awaited self.__session.send_custom_message("validation-jcheng5", results)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Here is a minimal reproducible example where the described error occurs when the disable button is clicked:

from shiny import Inputs, Outputs, Session, App, ui, reactive
from shiny_validate import InputValidator, check

app_ui = ui.page_fluid(
    ui.input_text("email_address", "Email Address"),
    ui.input_action_button("disable", "Disable"),
)

def server(input: Inputs, output: Outputs, session: Session):
    iv = InputValidator()
    iv.add_rule("email_address", check.required())
    iv.add_rule("email_address", check.email())
    
    iv.enable()
    
    @reactive.effect
    @reactive.event(input.disable)
    def _():
        iv.disable()

app = App(app_ui, server)

Thank you for your assistance in resolving this issue

@cs42
Copy link

cs42 commented Jan 8, 2025

InputValidator.__session.send_custom_message is an async method. In InputValidator.enable() is code, to await this, but in disable() it's missing. IMO this needs to be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants