twisted のアプリケーション フレームワークを使用するプロキシ サーバーを作成しました。コアでは、DHT を使用して問題を解決します。DHT クライアントの起動には数秒かかるため、DHT の準備が整った後にのみプロキシが接続を受け入れるようにしたいと考えています。
# there is a class like
class EntangledDHT(object):
# connects to the dht
# create the client
dht = EntangledDHT.from_config(config)
# when it can be used this deferred fires
# i want to wait for this before creating the "real" application
dht.ready
# the proxy server, it uses the dht client
port = config.getint(section, 'port')
p = CosipProxy(host=config.get(section, 'listen'),
port=port,
dht=dht,
domain=config.get(section, 'domain'))
## for twistd
application = service.Application('cosip')
serv = internet.UDPServer(port, p)
serv.setServiceParent(service.IService(application))
EntangledDHT
を、サービスを開始する前に Twisted が待機するある種のサービスにするにはどうすればよいCosipProxy
ですか? 私のためにこれを行うツイストのメカニズムはありますか? またはdht.ready
、アプリケーションの残りの部分を作成するコールバックを追加する必要がありますか? ありがとう