Opened 4 years ago

Closed 4 years ago

#7378 enhancement closed duplicate (duplicate)

Deferred dispatcher needed to coordinate many observers of one event

Reported by: dawuud Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


I am collaborating with the txtorcon author Meejah to design and implement the Tor Hidden Service endpoint class and parser... We'd like the txtorcon Tor hidden service endpoint to only launch a single instance of tor per python process... even if there are multiple endpoints whose "listen" method is called before the tor process is booted. They should all be "observers" of the tor process booting; upon bootup a "dispatcher/coordinator" class should fire a value to all the accumulated deferreds.

My current prototype uses a DeferredDispatcher I wrote to coordinate the booting of the tor process with multiple endpoint listen deferreds:

Apparently it is fairly common to write such deferred dispatching classes. Zooko pointed out to me that Brian Warner wrote one called OneShotObserverList here:

This implementation uses Brian Warner's "eventually" from Foolscap:

Obviously his code is higher quality than mine... but also it seems his implementation is more "cooperative" than mine because instead of firing all the deferred upon observed event completion it instead fires them all "eventually" via a reactor.callLater(0, ..)

To me this seems like a common enough deferred idiom to include in Twisted core api. What do people think of this?

Change History (1)

comment:1 Changed 4 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

More or less a duplicate of #6365.

Note: See TracTickets for help on using tickets.