2016-04-08 146 views
0

所以這是一個基本的客戶端服務器套接字程序。客戶端將文件發送到服務器,服務器使用gedit打開它。如何檢查文本文件是否在gedit中打開

p = subprocess.Popen("gedit file", shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) 

我想要的代碼像

while file_open in gedit: 
      wait() 
after file_closed and saved 
      send to client 
+0

可能重複的[Python:檢查文件被鎖定](http://stackoverflow.com/questions/13371444/python-check-file-is-locked) – CarlosCarucce

回答

0
while p.is_alive(): 
    ... 

我猜的工作......但真的會只保留只要去的過程中(gedit中)打開......他們可能已關閉該特定文件...