Services dependency and interaction in Twisted Python

点点圈 提交于 2019-12-11 07:52:04

问题


while working on Twisted, I was wondering if there is:

  1. a way to explicitly define services dependencies (e.g. in order to start service B, before I need to fire service A)
  2. a "pythonic" way to make two services communicate (e.g. B shares information with A, A can control B execution)

Thanks


回答1:


Take a look at Twisted Application Documentation. It sounds like you want to create a MultiService each with its own sub-Service implementation. What you do is define a number of services, implementing a startService and stopService and arrange your services in a tree hierarchy (via setServiceParent) to determine arbitrary startup and shutdown orderings.

If you're more interested in distributed service coordination, then that is slightly more difficult. This is something Erlang excels at, though if you're not averse to using a system like Zookeeper that could be a solution.

As to your final point, there are a number of ways for services to communicate. You can use something like Perspective Broker for object communication, or go for something more heavy and generalized like RabbitMQ



来源:https://stackoverflow.com/questions/5287142/services-dependency-and-interaction-in-twisted-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!