# -*- coding: utf-8 -*- from twisted.web import xmlrpc, server from twisted.internet import reactor, threads from twisted.internet.defer import Deferred class HyperminusD(xmlrpc.XMLRPC): def xmlrpc_echo(self, x): return x def xmlrpc_block(self, duration=10): import time d = Deferred() d = threads.deferToThread(time.sleep, duration) d.addCallback(lambda r: "i slept %d seconds!" % duration) return d # this only runs if the module was *not* imported if __name__ == '__main__': r = HyperminusD() reactor.listenTCP(7080, server.Site(r)) reactor.run()