[Twisted-Python] twisted/runner/inetdtap.py pyflakes warnings cleanup

Glyph Lefkowitz glyph at twistedmatrix.com
Sun Nov 22 18:13:57 MST 2015


> On Nov 22, 2015, at 16:31, Adi Roiban <adi at roiban.ro> wrote:
> 
> Hi,
> 
> Right now  twisted/runner/inetdtap.py has the following errors reported by pyflakes:
> 
> $ pyflakes twisted/runner/inetdtap.py
> twisted/runner/inetdtap.py:58: undefined name 'rpcVersions'
> twisted/runner/inetdtap.py:59: undefined name 'name'
> twisted/runner/inetdtap.py:62: undefined name 'p'
> twisted/runner/inetdtap.py:152: undefined name 'proto'
> 
> From what I can see from reading the code, RPCServer.startService is broken.
> 
> makeService is also broken for rpc/* services .
> 
> There are no tests for all this code.
> 
> Link for the code : 
> https://github.com/twisted/twisted/blob/trunk/twisted/runner/inetdtap.py <https://github.com/twisted/twisted/blob/trunk/twisted/runner/inetdtap.py>
> 
> ----------
> 
> I am working on getting the Twisted code clean of pyflakes errors/warnings so that contributors could run pyflakes check on their own branch, without relying on buildbot.

Thank you.  This would be absolutely great.

> I would like to clean the inetdtap.py module of pylakes warning but since it is broken and has no tests, I have no idea what this code is expected to do and how end users are expecting to use it. 

The purpose of inetdtap is to provide an 'inetd'-like server, to allow Twisted to invoke other programs to handle incoming sockets.  This is a useful thing as a "networking swiss army knife" tool, like netcat.  In fact, it does work, after a fashion; I wrote a file like this:

8123       stream  tcp  wait glyph  /bin/cat -

and then ran this:

put a blank line into 'rpc.conf', and then ran:

twistd -n inetd -f sampleinetd.conf -r rpc.conf 

and port 8123 properly became an echo server.

Now, in order to do this, you need a /etc/services file (this is hard-coded) that can be parsed by ServicesConf, which is _extremely_ picky, and probably the one that your OS comes with is still broken anyway.  But this code can work if properly configured, and those parts can be fixed.

I haven't run this recently, but partially only because I basically forgot it existed :).  Thanks for the reminder.

> Does someone volunteer to fix it?

I'll gladly fix the parts that implement the possibly-useful functionality, although you don't need to touch those in order to fix the pyflakes warnings :).  The parts that are totally broken, RPCServicesConf, RPCServer, and the code that instantiates it, are useful only to NFS server implementors, and don't work at all no matter your configuration.  So I would delete the whole implementation just so someone will get a clear notification in case they were importing one of these names but not actually using them, deprecate the module attributes, and remove them in the next available removal cycle.  So basically just leave an empty Service subclass there just as a courtesy (since that is slightly more polite, and only a tiny bit harder than just deleting it).

> Otherwise, has anyone any objections against deprecating twisted/runner/inetdtap.py?
> Since it is broken, can we just remove it?

I hope my suggestion makes sense and is useful.  However if you'd really like to do the compat-breaking dance I won't object; I seriously doubt anyone is touching the RPC code.  I'd prefer you don't delete the whole module though.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20151122/0bd6ca26/attachment-0002.html>


More information about the Twisted-Python mailing list