[Twisted-Python] Using DeferredList, on the remote method get parameter of None type?

yangyouxiu yangyouxiu at gmail.com
Wed Mar 5 07:35:18 MST 2014


When developing server-client software, on the client i call the method getTrafficDate, but on the server end, i got nio is None(d2=d.addCallback(lambda object: object.callRemote("getNIOTrafficInfo", node, nio)))
,so, what's the key point?

Thanks all!
-------------------------------------------------------------------------------------------------------------
client end
def getTrafficDate(self):
       if self.interfacenio_dict is not None and self.k:
            nodelist = self.interfacenio_dict.keys()
            trafficDataList=[]#DeferredList
            for node in nodelist:
                interfaces=self.interfacenio_dict[node]['interfaceinfo'].keys()
                if len(interfaces):
                    for interface in interfaces:
                        nio= self.interfacenio_dict[node]['interfaceinfo'][interface]
                        if nio is not None:
                            if 'nio_tap' in nio or 'NIO_NF_tap' in nio:
                                d= globals.perspective.callRemote('getServerRoot')
                                d2=d.addCallback(lambda object: object.callRemote("getNIOTrafficInfo", node, nio))
                                d2.addCallback(self.setTrafficSpeed_Tap, node, interface)
                                trafficDataList.append(d2)
                            else:
                                d= globals.perspective.callRemote('getServerRoot')
                                d2=d.addCallback(lambda object: object.callRemote("getNIOTrafficInfo", node, nio))
                                d2.addCallback(self.setTrafficSpeed_NotTap, node, interface)
                                trafficDataList.append(d2)
            
            trafficDataDeferredList=defer.DeferredList(trafficDataList, consumeErrors=True)
            trafficDataDeferredList.addCallback(self.getTrafficDataHandle)


server end
def remote_getNIOTrafficInfo(self,node,nio):
print nio
 if nio.name==nioName:
    pass

Bug info is:
File "/home/gddw/Documents/gddw-server-branche/src/Server.py", line 154, in remote_getNIOTrafficInfo
    if nio.name==nioName:
exceptions.AttributeError: 'NoneType' object has no attribute 'name'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140305/4a117f91/attachment.html>


More information about the Twisted-Python mailing list