Ejemplo n.º 1
0
    def execute(self):
        factory = WampServerFactory("ws://localhost:17998", debug = False, debugWamp = False)
        factory.protocol = PlywoodWebSocketServerProtocol
        factory.setProtocolOptions(allowHixie76 = True)

        listenWS(factory)

        reactor.run(installSignalHandlers=0) 
Ejemplo n.º 2
0
        """
      A method that we remote by using the exportRpc decorator.
      """
        return x + y

    def doSub(self, x, y):
        """
      A method that we remote explicitly.
      """
        return x - y


if __name__ == '__main__':

    if len(sys.argv) > 1 and sys.argv[1] == 'debug':
        log.startLogging(sys.stdout)
        debug = True
    else:
        debug = False

    factory = WampServerFactory("ws://localhost:9000", debugWamp=debug)
    factory.protocol = RpcServer1Protocol
    factory.setProtocolOptions(allowHixie76=True)
    listenWS(factory)

    webdir = File(".")
    web = Site(webdir)
    reactor.listenTCP(8080, web)

    reactor.run()
Ejemplo n.º 3
0
   @exportRpc("wsum")
   def workerSum(self, list, delay):
      ## Execute a slow function on thread from background thread pool.
      def wsum(list):
         if delay > 0:
            time.sleep(delay)
         return self.sum(list)
      return threads.deferToThread(wsum, list)


if __name__ == '__main__':

   if len(sys.argv) > 1 and sys.argv[1] == 'debug':
      log.startLogging(sys.stdout)
      debug = True
   else:
      debug = False

   factory = WampServerFactory("ws://localhost:9000", debugWamp = debug)
   factory.protocol = SimpleServerProtocol
   factory.setProtocolOptions(allowHixie76 = True)
   factory.trackTimings = True
   listenWS(factory)

   poolSize = 5
   print "Thread pool size:", poolSize

   reactor.suggestThreadPoolSize(poolSize)
   reactor.run()