Expected python bug using multiprocessing and inheritance

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

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
35/100
Loại issue
Lỗi
Độ 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 bằng cách chạy reproducer được cung cấp trên Python 3.9.12 và theo dõi cách multiprocessing xử lý target super().process được liên kết trong tiến trình con. So sánh điều này với target A.process tường minh; được xem là hoàn tất khi lệnh gọi đến superclass không còn đệ quy và vẫn giữ nguyên hành vi multiprocessing mong đợi.

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

Mô tả

stdlib type-bug

This is a bug report:

import time
import multiprocessing as mp
class A(object):
    def __init__(self, childnodes, **kwargs) -> None:
        self._childnodes = childnodes
        self._kwargs = kwargs

    def process(self, datablock, meta):
        print("Hello")
        time.sleep(1)
        print("world")

class B(A):
    def process(self, datablock, meta):
        print("before")
        mp.Process(target=super().process, args=(self, datablock, meta)).start()
        print("after")

if __name__ == "__main__":
    b = B([1,2,3])
    b.process([4,5,6], {'foo':42})

This seems to run forerever which is not expected. Reason seems to be that that somehow, super().process actually calls B.process instead of A.process in the subprocess. This is not expected behaviour. As additional evidence towards that, the program behaviour can be corrected by changing

mp.Process(target=super().process, args=(self, datablock, meta)).start()`meta)).start()

with

mp.Process(target=A.process, args=(self, datablock, meta)).start()

Machine:
MacBook Pro (16-inch, 2021)
MacOS Monteray 12.5
Chip: Apple M1 Max
Python version: 3.9.12

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.