Add `name` parameter to a `SharedMemoryManager.ShareableList` method

Đang mở Phù hợp với người mới
#96,215 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
60/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
operating-systems

Hướng nghiên cứu

Bắt đầu trong Lib/multiprocessing/managers.py, tại phương thức SharedMemoryManager.ShareableList gần cuối tệp, sau đó so sánh với tham số name của shared_memory.ShareableList. Hoàn tất khi phương thức của manager chấp nhận và chuyển tiếp name, đồng thời vẫn giữ nguyên hành vi theo dõi và dọn dẹp.

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

Mô tả

stdlib type-feature

Feature or enhancement

I would like to pass a name for shared list from SharedMemoryManager but I apparently cannot do this.

with SharedMemoryManager() as smm:
    my_shared_list = smm.ShareableList(sequence=range(10),name="special name")
    pass

What I get:

my_shared_list = smm.ShareableList(sequence=range(10),name="special name")
TypeError: SharedMemoryManager.ShareableList() got an unexpected keyword argument 'name'

Possible solution

Just change method ShareableList in the bottom of this source file to following:

        def ShareableList(self, sequence, name=None):
            """Returns a new ShareableList instance populated with the values
            from the input sequence, to be tracked by the manager."""
            with self._Client(self._address, authkey=self._authkey) as conn:
                sl = shared_memory.ShareableList(sequence=sequence,name=name)
                try:
                    dispatch(conn, None, 'track_segment', (sl.shm.name,))
                except BaseException as e:
                    sl.shm.unlink()
                    raise e
            return sl

I wonder

Why this feature is not implemented from the very beggining?

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

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.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

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.