“命名管道”又名“命名管线”(Named Pipes),是一种简单的进程间通信(IPC)机制,Microsoft Windows大都提供了对它的支持(但不包括Windows CE)。命名管道可在同一台计算机的不同进程之间或在跨越一个网络的不同计算机的不同进程之间,支持可靠的、单向或双向的数据通信。推荐用命名管道作为进程通信方案的一项重要的原因是它们充分利用了Windows内建的安全特性(ACL等)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
import glob


def look_for_files(dir_to_look):
"""Looks for windows in a given directory. Supports the * wildcard character"""
found_files = []
if "*" in dir_to_look:
found_files += glob.glob(dir_to_look)
elif os.path.exists(dir_to_look):
found_files.append(dir_to_look)
return found_files

def test():
for p in look_for_files('\\\\.\\pipe\\*'):
yield p

for i in test():
print(i)