@change Listeners Bypass Uncaught Exception Life Cycle

Abierto
#103 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

Start with the exception example at examples/exceptions/app_trame.py and reproduce the issue by adding the shown @change listener that raises an error. The issue says this began in trame-server==3.13.2 after #95; inspect that change and trace how listener exceptions reach the life cycle handler. Done when the exception life cycle event fires for errors raised by a @change listener.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

If you take the exception example and add a @change listener with an error in the code, the life cycle event will be bypassed.

This did not start occurring until trame-server==3.13.2 after #95.

Modified app_trame.py Example

Click to expand
import logging
import sys
import traceback

from trame.app import TrameApp
from trame.ui.html import DivLayout
from trame.widgets import html

from trame.decorators import change, life_cycle

# Disable default stdout exception
logging.getLogger("wslink.protocol").setLevel(logging.CRITICAL)


class MonitorException(TrameApp):
    def __init__(self, server=None):
        super().__init__(server)
        self.server.state.test = 1
        self._build_ui()
        # self.ctrl.on_exception.add(self.on_exception)

    def _build_ui(self):
        with DivLayout(self.server) as self.ui:
            html.Button("Divide by 0", click=self.divide_by_zero)
            html.Button("JS error", click="console.error('Yo')")
            html.Button("Divide by 0 in change listener", click="test += 1")

    def divide_by_zero(self):
        return 1 / 0

    @life_cycle.exception
    def on_exception(self, exception):
        print(">" * 60)
        print("exception ->", exception)
        traceback.print_exception(
            type(exception), exception, exception.__traceback__, file=sys.stdout
        )
        print("<" * 60)

    @life_cycle.error
    def on_js_error(self, msg):
        if msg == "[object Object]":
            # exception... => should fix JS to send a better msg/event
            return

        print("JS error:", msg)

    @change("test")
    def test_is_changed(self, **_):
        return 1 / 0


def main():
    app = MonitorException()
    app.server.start()


if __name__ == "__main__":
    main()

Lenguaje dominante
Python
Estrellas
17
Forks
16
Merge medio
1 d 15 h
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Kitware/trame-server

Todos los issues de Kitware/trame-server

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.