python / python/cpython

`select.BaseSelector.select` do not conform to documentation with regard to signal handling

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

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

topic-socket type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Bug report

Bug description:

According to documentation in https://docs.python.org/3/library/selectors.html#selectors.BaseSelector.select:

      .. versionchanged:: 3.5
         The selector is now retried with a recomputed timeout when interrupted
         by a signal if the signal handler did not raise an exception (see
         :pep:`475` for the rationale), instead of returning an empty list
         of events before the timeout.

However, as of writing this issue, selectors.SelectSelector.select and co can't differentiate between InterruptedError and timeout, as this exceptions is caught in in those methods.

While select.select shouldn't raise InterruptedError, such exception could be raised in a signal handler, therefore causing selectors.SelectSelector.select to return an empty list (instead of the raised exception), as-if it was a timeout.

The behaviour that I would expect has been implemented in https://github.com/python/cpython/commit/f70e1ca0fc30426d12aa8fc6684764ee11a66777, however it has been reverted in a following commit https://github.com/python/cpython/commit/90ecfe65e68#diff-671465c62a2c7c951b397550dc8f2f1c03860af4c089299e6edea29347cf6018 . It is unclear to me if it is an oversight, or if this revert was expected.

I only tested this for selectors.SelectSelector, but looking at the sources, I would expect the same behaviour exist for all select.*Selector classes

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-120002

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

Mở hướng dẫn đóng góp

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 với selectors.SelectSelector.select và so sánh cách nó xử lý các gián đoạn tín hiệu với hành vi được ghi chép của BaseSelector.select. Kiểm tra PR được liên kết gh-120002 và các commit được tham chiếu để hiểu cách giải quyết dự kiến, sau đó xác minh xem các lớp select.*Selector có cần được xử lý nhất quán và có kiểm thử hồi quy hay không.

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
operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
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.