我以前做的項目與標準輸入子管材連接一個遙遠的VIM(我的服務器上),我的客戶,通過標準輸出SSL套接字。我使用Python 3.4。 我的套接字(代碼中的cSock)是SSL封裝的,每次我嘗試打開Vim時我都有同樣的錯誤。在這裏我的代碼:的Python 3.4 ssl.SSLEOFError:EOF發生違反協議(_ssl.c:1638)
vimProc = sp.Popen(["rvim", file], bufsize=0, stdin=sp.PIPE, stdout=sp.PIPE)
cSock.settimeout(1)
rec = Reception(cSock, vimProc)
emi = Emission(cSock, vimProc)
rec.start()
emi.start()
rec.join()
emi.join()
在這裏,我接待的線程和排放
class Reception(threading.Thread):
def __init__(self, sock, proc):
threading.Thread.__init__(self)
self.sock = sock
self.proc = proc
def run(self):
while self.proc.poll() == None:
try:
self.proc.communicate(self.sock.recv(1))
except socket.timeout:
pass
class Emission(threading.Thread):
def __init__(self, sock, proc):
threading.Thread.__init__(self)
self.sock = sock
self.proc = proc
def run(self):
while self.proc.poll() == None:
try:
outs = self.proc.stdout.read(1)
if outs == "":
print("EOF reached")
else:
self.sock.send(outs)
except socket.timeout:
pass
這裏回溯:
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File ".../server/edition.py", line 62, in run
self.sock.send(outs)
File "/usr/lib/python3.4/ssl.py", line 678, in send
v = self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1638)
任何解決方案?
嗯,我發現這個問題。 'if buf ==「」:'沒有看到EOF字符,但是「如果buf:'工作得很好。 非常感謝您的幫助@Steffen Ullrich! – Xysto