[Twisted-Python] How do I debug this network problem?

Glyph glyph at twistedmatrix.com
Thu Nov 13 06:17:19 MST 2014


> On Nov 13, 2014, at 1:15 PM, Peter Westlake <peter.westlake at pobox.com> wrote:
> 
> I've had a look at the code, and got rather lost amongst the interfaces
> and inheritance and protocols and transports. If someone can help me
> narrow down the relevant bits of code, I can put in some Python tracing.
> 

I could describe all the interfaces and inheritance and protocols and transports, but since you don't want to puzzle out all that code, presumably such a description would be overly complex :).

A good place to start would be to figure out if the data is getting to Twisted at all, which means instrumenting your Protocol.

If you've done the default thing, and just done class Something(AMP):, this means you should override dataReceived, like so:

from __future__ import print_function
from twisted.protocols.amp import AMP
class MyAMP(AMP, object):
    def dataReceived(self, data):
        print("Got some data", repr(data))
        return super(MyAMP, self).dataReceived(data)

If you're not seeing anything, that will give you an idea of whether your kernel is not actually delivering that data to Twisted.

There are, of course, a plethora of other things that could be going wrong - maybe your Twisted program is stuck in some blocking function elsewhere and the reactor loop isn't running at all, maybe you're using some policy wrapper which is buffering incorrectly... but that's a good sanity check to start with.

-glyph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20141113/64afb8c9/attachment-0002.html>


More information about the Twisted-Python mailing list