from multiprocessing.connection import Connection
if isinstance(f, Connection):
print("f is a Connection to a Pipe")
from multiprocessing.dummy.connection import Connection
There are significant implementation differences between Python 2 and 3 w. r. t. multiprocessing Connection objects. In Python 2, you can import them via:
from _multiprocessing import Connection
In Python 2, the
Connection class is implemented in a helper module
_multiprocessing, written in C (source here). I think it is written in C for better accessibility of the Windows API and possibly for performance reasons. I assume that in case of Python 3 the special Windows API calls required for implementing named pipes have been externalized to the winapi module.
You can easily, depending on the Python version, either import Connection from
multiprocessing.connection or from
_multiprocessing so that your code runs on both, Python 2 and 3.