全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

登錄


全部 新建 登錄

All gists matching topic pipe

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新

timmy / 使用 multiprocessing.Pipe 進行進程間通訊

0 喜歡
0 分支
1 檔案
最後活躍 9 months ago
multiprocessing.Pipe 允許 Python 進程之間傳遞資料,適用於需要高效能、雙向通訊的場景,如併發運算或分佈式處理。
concurrency ipc multiprocessing parallel-processing pipe python
1 from multiprocessing import Process, Pipe
2
3 def worker(conn):
4 conn.send("Hello from child process") # 傳送訊息
5 msg = conn.recv() # 接收訊息
6 print(f"Child received: {msg}")
7 conn.close()
8
9 if __name__ == "__main__":
10 parent_conn, child_conn = Pipe() # 建立 Pipe 雙向通道
上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 23ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文