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

On Windows set_interval blocks a full exit of the application until the next interval fires #2711

Closed
davep opened this issue Jun 1, 2023 · 2 comments · Fixed by #2758
Closed
Labels
bug Something isn't working Task

Comments

@davep
Copy link
Collaborator

davep commented Jun 1, 2023

Take this code as an example:

from textual.app        import App, ComposeResult
from textual.containers import Center
from textual.reactive   import var
from textual.widgets    import Label

class WindowsIntervalBugApp( App[ None ] ):

    CSS = """
    Screen {
        align: center middle;
    }
    """

    counter: var[int] = var(0)

    def compose( self ) -> ComposeResult:
        yield Center( Label() )

    def watch_counter( self ) -> None:
        self.query_one( Label ).update( str( self.counter ) )

    def bump_counter( self ) -> None:
        self.counter += 1

    def on_mount( self ) -> None:
        self.set_interval( 30, self.bump_counter )

if __name__ == "__main__":
    WindowsIntervalBugApp().run()

When run on macOS, if you run it up and then Ctrl+C right away, the application instantly exits. On Windows, the display of the application will close down but you don't get your shell prompt back for around 30 seconds, minus the time it took you to Ctrl+C.

I've not tested this yet but I suspect the same would be true with set_timer as well.

@davep davep added bug Something isn't working Task labels Jun 1, 2023
davep added a commit to davep/textual-sandbox that referenced this issue Jun 1, 2023
@willmcgugan
Copy link
Collaborator

We need to implement a cancelable timer on Windows.

Talk to @willmcgugan before attempting this.

@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants