#! /usr/bin/python from twisted.internet.app import Application from twisted.internet import reactor from twisted.spread import pb class MyException(pb.Error): pass class One(pb.Root): def remote_fooMethod(self, arg): if arg == "panic!": raise MyException return "response" def remote_shutdown(self): reactor.stop() app = Application("trap_server") app.listenTCP(8800, pb.BrokerFactory(One())) app.run(save=0)