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

LinuxDriver: Exit if thread dies #3431

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/textual/drivers/linux_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import TYPE_CHECKING, Any

import rich.repr
import rich.traceback

from .. import events, log
from .._xterm_parser import XTermParser
Expand Down Expand Up @@ -265,6 +266,13 @@ def more_data() -> bool:
for event in feed(unicode_data):
self.process_event(event)
except Exception as error:
log(error)
self._app.exit(
return_code=1,
message=rich.traceback.Traceback.from_exception(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to call app.panic here. But bear in mind that neither exit or panic are threadsafe. It's probably wise to use app.call_later to ensure that panic is called in the main thread.

BTW I don't think you'll need all those parameters to Traceback. If you construct Traceback() in a handler it will detect the traceback automatically.

exc_type=type(error),
exc_value=error,
traceback=error.__traceback__,
),
)
finally:
selector.close()