Post a message to this widget. Args: message: Message to post. Returns: True if the message was posted, False if this widget was closed / closing.
(self, message: Message)
| 4484 | await self.app.run_action(action, self, namespaces) |
| 4485 | |
| 4486 | def post_message(self, message: Message) -> bool: |
| 4487 | """Post a message to this widget. |
| 4488 | |
| 4489 | Args: |
| 4490 | message: Message to post. |
| 4491 | |
| 4492 | Returns: |
| 4493 | True if the message was posted, False if this widget was closed / closing. |
| 4494 | """ |
| 4495 | _rich_traceback_omit = True |
| 4496 | # Catch a common error. |
| 4497 | # This will error anyway, but at least we can offer a helpful message here. |
| 4498 | if not hasattr(message, "_prevent"): |
| 4499 | raise RuntimeError( |
| 4500 | f"{type(message)!r} is missing expected attributes; did you forget to call super().__init__() in the constructor?" |
| 4501 | ) |
| 4502 | |
| 4503 | if constants.DEBUG and not self.is_running and not message.no_dispatch: |
| 4504 | try: |
| 4505 | self.log.warning(self, f"IS NOT RUNNING, {message!r} not sent") |
| 4506 | except NoActiveAppError: |
| 4507 | pass |
| 4508 | return super().post_message(message) |
| 4509 | |
| 4510 | async def on_prune(self, event: messages.Prune) -> None: |
| 4511 | """Close message loop when asked to prune.""" |
no test coverage detected