All pastes #225006 Raw Edit

gwenn

public python v1 · immutable
#225006 ·published 2006-10-27 18:20 UTC
rendered paste body
# -*- coding: utf-8 -*-from twisted.web import xmlrpc, serverfrom twisted.internet import reactor, threadsfrom twisted.internet.defer import Deferredclass 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* importedif __name__ == '__main__':    r = HyperminusD()    reactor.listenTCP(7080, server.Site(r))    reactor.run()