【发布时间】:2009-08-09 08:57:13
【问题描述】:
我正在用 Python 编写一个迷你 FTP 服务器,它像 FTP 一样公开底层数据库。流程是这样的:
sock.send("150 Here's the file you wanted\r\n")
proc = Popen2(...)
for parts in data:
data_sock.send(parts)
proc.kill()
sock.send("226 There's the file you wanted\r\n")
data_sock.shutdown(0)
data_sock.close()
data_sock 是已启动并工作的 PASV 套接字,由 Wireshark 确认。实际发生的情况是在第 163,328 个字节通过 data_sock 发送后,data_sock.send() 行就挂起。我怀疑发送缓冲区已满,但我不明白为什么 FTP 客户端不会从 PASV 套接字读取数据。
我已经包含了 Popen2(...) 行,因为我已经设法在 OS X 上重现 http://bugs.python.org/issue3006 ——在 Popen 进程被终止之前,套接字不会关闭。不确定这是否有某种关系。
【问题讨论】: