raising resource warnings prevents resource cleanup
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với Lib/asyncio/unix_events.py tại các dòng được liên kết và tìm những nơi khác mà ResourceWarning được phát ra trước khi dọn dẹp tài nguyên. Kiểm tra các đường dẫn dọn dẹp bị ảnh hưởng bằng -Werror hoặc filterwarnings=['error', ...]. Hoàn tất khi việc nâng cấp cảnh báo không còn ngăn tài nguyên bên dưới được đóng nữa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
in a number of places a ResourceWarning is issued before cleaning up a resource eg
https://github.com/python/cpython/blob/944ff8c57c9e8ff5a5bd18925070ddb1504490ab/Lib/asyncio/unix_events.py#L559-L562
normally this is fine - however if you're running with -Werror these warnings are raised as exceptions and so prevent the underlying resource from being cleaned up. This is in particular a problem when running a test suite with filterwarnings=['error', ... where resource cleanup can be delayed for many tests.
I think these should instead be restructured as:
def __del__(self, _warn=warnings.warn):
if self._pipe is not None:
msg = f"unclosed transport {self!r}" # grab the repr before closing the pipe so it displays as "open" still
self._pipe.close()
_warn(msg, ResourceWarning, source=self) # issue the warning after closing the resource
Your environment
- CPython versions tested on:
- Operating system and architecture:
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
docs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
stdlib topic-email type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Tất cả issue của python/cpython
Issue tương tự
-
link-check link-check:sphinx-theme
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
OpenHands/extensions#626 · 1 bình luận ·
-
Change observation tooltip text Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
CSCfi/sd-search-api#39 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100