tarantool / tarantool/tarantool-python

Refactor connection errors

Đang mở
#174 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug Database API
Ngôn ngữ chính
Python
Star
108
Fork
51
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách lần theo hệ thống phân cấp ngoại lệ và các điểm vào kết nối được nêu trong issue: connect(), handshake() và _opt_reconnect(). Xem xét NetworkError, OperationalError, SchemaReloadException, Warning, NetworkWarning và ClusterDiscoveryWarning, sau đó so sánh hành vi được yêu cầu của hệ thống phân cấp và thông báo với tiêu chuẩn Database API liên quan. Hoàn tất có nghĩa là các lỗi còn lại của connector và các lỗi kết nối lại tuân theo hệ thống phân cấp dự kiến, đồng thời hành vi cảnh báo được định nghĩa và bao phủ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend, databases
Loại issue
Tái cấu trúc
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.