tarantool / tarantool/tarantool-python
Refactor connection errors
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 108
- Forks
- 51
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 1
Descripción
NetworkError is the case of OperationalError in fact. Moreover, .execute() can raise NetworkError and it'll contradict to the standard if NetworkError will not be a child of OperationalError:
The module should make all error information available through these exceptions or subclasses thereof:
The standard says "should" (not "must"), but I guess it may be important if an application or a library implements some retrying strategy based on a type of an error. OperationalError is transient by its meaning and can be retried.
SchemaReloadException also looks as a child of OperationalError. It should not be visible for a user, but while we have the whole hierarchy implement, it looks meaningful to either move SchemaReloadException outside of it or inherit properly.
More generally, all errors that base connector raises should be within this hierarchy, otherwise it will not be userful in practice. I left separate comments for other standard errors, where existing errors should be child of them.
=============
The Warning class is not used anywhere now and is not connected to existing NetworkWarning and ClusterDiscoveryWarning warnings. Now those warnings are just emitted using standard warnings module (see warn() function below), but it is not flexible enough to implement Cursor.messages and Connection.messages Database API extensions. We should provide API for tarantool.connection that allows to redefine this behaviour and collect those warnings after a request as sequence of tuples (exception class, exception value) as defined in the Database API. It'll be base for implementing the Database API <...>.messages extensions.
It is unclear for me, whether 'exception class' should be a subclass of this Warning class or warnings.UserWarning (we should inherit it from StandardError, not warnigns.Warning, which in a child of Exception). It is unclear, what exatcly 'exception value' should be: an instance of this Warning class or arbitrary value that describes what exactly appears? I would look to other implementations to better understand the idea of the standard.
=============
self.handshake() call in _opt_reconnect() should be try-catched and its error should be wrapped into NetworkError like it is done in connect(). Otherwise Exception or ValueError may lift up to a user, which is not expectable I guess.
Maybe there are other similar places, need to look around the code.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza rastreando la jerarquía de excepciones y los puntos de entrada de conexión mencionados en el issue: connect(), handshake() y _opt_reconnect(). Revisa NetworkError, OperationalError, SchemaReloadException, Warning, NetworkWarning y ClusterDiscoveryWarning; después, compara el comportamiento solicitado de la jerarquía y de los mensajes con el estándar relevante de Database API. Se considera terminado cuando los errores restantes del conector y los fallos de reconexión siguen la jerarquía prevista y el comportamiento de las advertencias está definido y cubierto.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend, databases
- Tipo de issue
- Refactorización
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100