publish-subscribe pattern self subscribers self topic_subscribers[topicset(return "okdef send(selfmessage)print("sending message:\ntopic{}\npayload{}format(message["topic"]message["payload"])for subscriber in self topic_subscribers [message get("topic""all")]with serverproxy(subscriberas subscriber_proxysubscriber_proxy process(messagereturn "okdef main()dispatch_server dispatcher(dispatch_server serve_forever(if __name__ ="__main__"main(publisher py from xmlrpc client import serverproxy class publisher(object)def __init__(selfdispatcher)self dispatcher dispatcher def publish(selfmessage)with serverproxy(self dispatcheras dispatchdispatch send(messagedef main()message {"topic""messagetopic""payload""this is an awesome payload"publisher publisher(publisher publish(messageif __name__ ="__main__"main(