Я пытаюсь разработать смешанный протокол, который может возвращать необработанный ответ или ответ на основе строки на основе запроса.Мой код выглядит как
class Receiver(LineReceiver):
def lineReceived(self, line):
(command, args) = self._parse_command(line)
result = self.exec_command(command, args) #Secret sauce returns list or blob.
if isinstance(result, basestring): # won't work in 3.0 ; least of my worries.
self.sendLine(str(len(result))) # Sends no. of bytes as a line.
self.transport.write(result) #followed by bytes. This is not received by the client.
self.transport.loseConnection()
else:
no_lines = len(result)
self.sendLine(str(no_lines))
for r in result:
self.sendLine(str(r))
. В приведенном выше коде transport.write (...) не отправляет данные клиенту.Как я могу это исправить.