[Twisted-Python] improving foolscap's use of Twisted

David Stainton dstainton415 at gmail.com
Sat Mar 8 03:02:31 MST 2014



Greetings,

My goal is to get Brian Warner's foolscap library ported to Twisted
endpoints instead of the older Twisted api interfaces it currently
uses (ClientFactory and IConnector).

This effort has been documented in foolscap trac ticket #203:
http://foolscap.lothar.com/trac/ticket/203

and also part of Tahoe-LAFS trac ticket #517 - make tahoe Tor- and I2P-friendly:
https://tahoe-lafs.org/trac/tahoe-lafs/ticket/517

My question is this:

Since Foolscap's TubConnectorClientFactory does rely
on clientConnectionFailed... What is the equivalent to this for the new
interfaces?

I have tried to braindump all my foolscap twisted endpoint thoughts to
foolscap trac ticket #203 :
http://foolscap.lothar.com/trac/ticket/203#comment:30
http://foolscap.lothar.com/trac/ticket/203#comment:31

If we look at line 1223 of
https://github.com/warner/foolscap/blob/master/foolscap/negotiate.py
(at 0395476c7cb154f925d67abf6858a8200126352b)

we see that there's this TubConnectorClientFactory:
class TubConnectorClientFactory(protocol.ClientFactory, object):

and later at line 1384 it is used with connectTCP like this:
            f = TubConnectorClientFactory(self, host, lp)
            c = reactor.connectTCP(host, port, f)

In my endpoints2 branch
(https://github.com/david415/foolscap/tree/endpoints2)
I changed it to:
class TubConnectorFactory(protocol.Factory, object):

I suspected that TubConnector?'s clientConnectionFailed doesn't get
called and then I found a relevent quaote this twisted doc:
https://twistedmatrix.com/documents/current/core/howto/endpoints.html

here's the quote:
"""Note: If you've used ClientFactory before, keep in mind that the
connect method takes a Factory, not a ClientFactory. Even if you pass a ClientFactory to
endpoint.connect, its clientConnectionFailed and clientConnectionLost
methods will not be called."""

Currently foolscap's extensive collection of unittests are exercising
bugs in my code when I try to port foolscap to twisted
endpoints.

foolscap$ trial foolscap.test.test_appserver.RunCommand.test_run
foolscap.test.test_appserver
  RunCommand
    test_run ...                                                        [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
Failure: foolscap.tokens.NegotiationError: no connection established within client timeout

foolscap.test.test_appserver.RunCommand.test_run
-------------------------------------------------------------------------------
Ran 1 tests in 60.576s

FAILED (errors=1)
foolscap$ 



Cheers!

David Stainton


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140308/55d9921f/attachment.pgp>


More information about the Twisted-Python mailing list