self.window += 1 self.close() #class Protocol(BeepServerProtocol): # def channelStarted(self, channelnum, uri): # # This is the real start. It occurs after success RPY is received on # # client side, and after success RPY is sent on server side. # channel = self.getChannel(channelnum) # channel.profile.channelStarted() #class Factory(BeepServerFactory): # protocol = Protocol factory = BeepListenerFactory() factory.addProfile(Profile.uri, profile.ProfileFactory(Profile)) reactor.listenTCP(7331, factory) def int_handler(signum, frame): def real_handler(): print "User interruption. Terminating" reactor.stop() reactor.callFromThread(real_handler) signal.signal(signal.SIGINT, int_handler) reactor.run() print "Done!"
return commands.getstatusoutput(" ".join([cmd] + args)) cmds = { # Format = { 'name': (function, run in thread) } "add": (add, False), "multiply": (multiply, False), "execute": (execute, True), } def int_handler(signum, frame): def real_handler(): print "User interruption. Terminating" reactor.stop() reactor.callFromThread(real_handler) signal.signal(signal.SIGINT, int_handler) factory = BeepListenerFactory() factory.addProfile(xmlrpcprofile.uri, profile.ProfileFactory(xmlrpcprofile.XmlRpcServer, cmds)) # Set up main loop to listen for connections reactor.listenTCP(7331, factory) # Main loop reactor.run() print "Done!"