-
Notifications
You must be signed in to change notification settings - Fork 815
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
App.on_unmount is called twice when running via pilot (App.run_test) #3246
Comments
Also I noticed there is a weird execution order. Consider: import asyncio
import logging
from textual.app import App
logging.basicConfig(handlers=[logging.StreamHandler()], level=logging.INFO)
logger = logging.getLogger("test")
async def test_on_unmount_ignoring_a_finally_block() -> None:
class MyApp(App[None]):
something = False
def on_mount(self):
self.something = True
async def on_unmount(self) -> None:
await self.close_something()
async def close_something(self) -> None:
if self.something:
logger.info("closing something")
try:
await self.very_slow_cleanup()
finally:
logger.info("setting something to False")
self.something = False
async def very_slow_cleanup(self):
logger.info("very_slow_cleanup started")
await asyncio.sleep(2)
logger.info("very_slow_cleanup finished")
async with MyApp().run_test():
pass
if __name__ == "__main__":
asyncio.run(test_on_unmount_ignoring_a_finally_block()) Now it causes the
while it should be:
|
Fixed. |
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
Textual version: 0.36.0
There seems to be an issue with pilot causing on_unmount to be called twice.
Consider the following code:
It results with AssertionError.
While this one is correct:
The text was updated successfully, but these errors were encountered: