如何派遣到Nameko的在职工人?

时间:2018-10-01 16:49:05

标签: python microservices nameko

我有websocket服务,用于打开流,接收消息等。我可以创建一个event_handler来打开新的连接,但不适用于将来的事件。这些将由新工作人员处理,那么如何与正在运行的工作人员/ greenthreads进行交互?

class ServiceA:
    """ Event dispatching service. """
    name = "service_a"

    dispatch = EventDispatcher()

    @rpc
    def dispatching_method(self, payload):
        self.dispatch("start_socket", payload)


class ServiceB:
    """ Event listening service. """
    name = "service_b"

    @event_handler("service_a", "start_socket")
    def start_socket(url):
        sock = websocket.start_socket(url)
        gr = eventlet.spawn(sock.run_forever)  

调用sock之后,如何与gr中的ServiceAstart_socket()进行交互?

0 个答案:

没有答案