Beispiel #1
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()
Beispiel #2
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()