Python 3.x 可以在Python 3中刷新multiprocessing.Pipe()吗

Python 3.x 可以在Python 3中刷新multiprocessing.Pipe()吗,python-3.x,Python 3.x,我不熟悉编码。根据我的理解,在关闭管道后,无法访问管道,因此管道中存在的项目。但是,我想在关闭管道之前冲洗管道中的所有项目。可能吗 import multiprocessing def child(r, w): r.close() for n in range(11): w.send(n) if __name__ == '__main__': r, w = multiprocessing.Pipe() p = multiprocessing.P

我不熟悉编码。根据我的理解,在关闭管道后,无法访问管道,因此管道中存在的项目。但是,我想在关闭管道之前冲洗管道中的所有项目。可能吗

import multiprocessing

def child(r, w):
    r.close()
    for n in range(11):
        w.send(n)

if __name__ == '__main__':
    r, w = multiprocessing.Pipe()
    p = multiprocessing.Process(target=child, args=(r, w))
    p.start()
    w.close()
    print("Item received by main:", r.recv())
    #flush
    if r.poll():
        print("Item still left on pipe:", r.recv())
    p.join()