当使用Twisted的UNIXClientEndpoint时,传输是非类型的

2024-09-30 01:24:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试用twisted实现一个简单的客户端,使用数据报和命名管道。在

我将协议定义如下:

class ConsoleProtocol(protocol.DatagramProtocol):

    def __init__(self, machine, console_path):
        self.console_path = console_path
        self.transport = None

    def datagramReceived(self, datagram, addr):
        self.logger.debug("datagramReceived()")
        # blah, doing stuff !

    def sendHalt(self):
        self.logger.debug("sending message to fifo %s", self.console_path)
        self.transport.write("ahaha", self.console_path)

并将其连接到UNIX客户端端点:

^{pr2}$

但是在执行sendHalt()方法时,传输参数是NoneType。在Twisted中使用UNIX客户端的正确方法是什么?在


Tags: 数据path方法debugself客户端defunix

热门问题