[Twisted-Python] tor hidden service endpoint parser returns a deferred

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri May 2 09:01:17 MDT 2014


On 02:53 pm, dstainton415 at gmail.com wrote:
>I get what you are saying... but let's back up a second;
>foolscap (in my branch
>https://github.com/david415/foolscap/tree/endpoint_descriptors_server2)
>uses clientFromString and serverFromString to translate twisted
>endpoint descriptors into endpoint objects... AND foolscap
>doesn't know any details about how the endpoint wire protocols work...
>and we'd like to keep it that way. That's really the point of this
>exercise.
>
>The calling party using foolscap... in this case Tahoe-LAFS also
>doesn't know anything about any wire protocols.
>It simply receives twisted endpoint descriptors from the user and
>passes them to foolscap.

But Foolscap does know about *endpoints*.  It knows to call `listen` or 
`connect` on them.  Both of those methods return a `Deferred`.  Any 
setup work you need to do you should be able to do in the implementation 
of those methods and however long it takes is how long it takes - just 
don't fire the `Deferred` until it is ready.

Jean-Paul



More information about the Twisted-Python mailing list