multiprocessing.Pipe和multiprocessing.connection.Pipe之间的区别

时间:2016-04-01 09:51:58

标签: python pipe multiprocessing

我发现python.org有multiprocessing.Pipe的官方文档,但是我的PyCharm IDE建议我导入multiprocessing.connection.Pipe,它没有文档。内置帮助系统如下:

>>> from multiprocessing import Pipe as P1
>>> from multiprocessing.connection import Pipe as P2    
>>> help(P1)
Help on method Pipe in module multiprocessing.context:

Pipe(duplex=True) method of multiprocessing.context.DefaultContext instance
    Returns two connection object connected by a pipe

>>> help(P2)
Help on function Pipe in module multiprocessing.connection:

Pipe(duplex=True)
    Returns pair of connection objects at either end of a pipe

那么有什么区别,我应该使用哪些文档?

1 个答案:

答案 0 :(得分:0)

我发现它实际上是同样的事情。在档案multiprocessing/context.py中,我找到了以下几行:

def Pipe(self, duplex=True):
    '''Returns two connection object connected by a pipe'''
    from .connection import Pipe
    return Pipe(duplex)