Пример #1
0
    def get_handler(self):
        if self.handler is None:
            self._worker = pulsar.get_actor()
            if not self.cms:
                self.cms = CMS(self)

            async_middleware, wsgi = self._build_handler()
            self.handler = wsgi
            self.fire('on_loaded')
            #
            # Using a green pool
            if self.green_pool:
                from pulsar.apps.greenio.wsgi import GreenWSGI
                wsgi = GreenWSGI(wsgi, self.green_pool)
                async_middleware.append(wsgi)
            else:
                if self.config['THREAD_POOL']:
                    wsgi = middleware_in_executor(wsgi)
                else:
                    wsgi = as_async_wsgi(wsgi)
                async_middleware.append(wait_for_body_middleware)
                async_middleware.append(wsgi)

            self.handler = WsgiHandler(async_middleware, async=True)
        return self.handler
Пример #2
0
    def get_handler(self):
        if self.handler is None:
            self._worker = pulsar.get_actor()
            if not self.cms:
                self.cms = CMS(self)

            async_middleware, wsgi = self._build_handler()
            self.handler = wsgi
            self.fire('on_loaded')
            #
            # Using a green pool
            if self.green_pool:
                from pulsar.apps.greenio.wsgi import GreenWSGI
                wsgi = GreenWSGI(wsgi, self.green_pool)
                async_middleware.append(wsgi)
            else:
                if self.config['THREAD_POOL']:
                    wsgi = middleware_in_executor(wsgi)
                else:
                    wsgi = as_async_wsgi(wsgi)
                async_middleware.append(wait_for_body_middleware)
                async_middleware.append(wsgi)

            self.handler = WsgiHandler(async_middleware, async=True)
        return self.handler
Пример #3
0
 def setup(self, environ=os.environ):
     app = self.getapp()
     middlewares = self.getmiddlemare() + [
         wsgi.wait_for_body_middleware,
         wsgi.middleware_in_executor(app)
     ]
     return wsgi.WsgiHandler(tuple(middlewares))
Пример #4
0
 def setup(self, environ=None):
     '''Set up the :class:`.WsgiHandler` the first time this
     middleware is accessed.
     '''
     from django.conf import settings
     from django.core.wsgi import get_wsgi_application
     #
     try:
         dotted = settings.WSGI_APPLICATION
     except AttributeError:  # pragma nocover
         dotted = None
     if dotted:
         return module_attribute(dotted)()
     else:
         app = middleware_in_executor(get_wsgi_application())
         return WsgiHandler((wait_for_body_middleware, app))
Пример #5
0
 def setup(self, environ=None):
     '''Set up the :class:`.WsgiHandler` the first time this
     middleware is accessed.
     '''
     from django.conf import settings
     from django.core.wsgi import get_wsgi_application
     #
     try:
         dotted = settings.WSGI_APPLICATION
     except AttributeError:  # pragma nocover
         dotted = None
     if dotted:
         app = module_attribute(dotted)
     else:
         app = get_wsgi_application()
     app = middleware_in_executor(app)
     return WsgiHandler((wait_for_body_middleware, app), async=True)
Пример #6
0
    def get_handler(self):
        if self.handler is None:
            self._worker = pulsar.get_actor()
            self.cms = CMS(self)
            self.handler = self._build_handler()
            self.fire('on_loaded')
            wsgi = None
            if self.green_pool:
                self.logger.info('Setup green Wsgi handler')
                wsgi = WsgiGreen(self.handler, self.green_pool)
            elif self.thread_pool:
                wsgi = middleware_in_executor(self.handler)

            if wsgi:
                self.handler = WsgiHandler((wait_for_body_middleware, wsgi),
                                           async=True)
        return self.handler
Пример #7
0
 def setup(self, environ=None):
     '''Set up the :class:`.WsgiHandler` the first time this
     middleware is accessed.
     '''
     from django.conf import settings
     from django.core.wsgi import get_wsgi_application
     #
     app = get_wsgi_application()
     green_workers = self.cfg.greenlet if self.cfg else 0
     if greenio and green_workers:
         if pg:
             pg.make_asynchronous()
         app = greenio.RunInPool(app, green_workers)
         self.green_safe_connections()
     else:
         app = middleware_in_executor(app)
     return WsgiHandler((wait_for_body_middleware, app))
Пример #8
0
 def setup(self, environ):
     cfg = environ['pulsar.cfg']
     mapper = odm.Mapper(cfg.engine)
     #
     # Register the two alchemy models
     mapper.register(World)
     mapper.register(Fortune)
     #
     route = Router('/', mapper=mapper)
     #
     # Concurrency method
     if mapper.is_green:
         # Use pool of greenlets
         pool = GreenWSGI(route, GreenPool(cfg.thread_workers))
     else:
         # Use pool of threads
         pool = wsgi.middleware_in_executor(route)
     return wsgi.WsgiHandler((wsgi.wait_for_body_middleware, pool),
                             async=True)
Пример #9
0
 def setup(self, environ=None):
     '''Set up the :class:`.WsgiHandler` the first time this
     middleware is accessed.
     '''
     from django.conf import settings
     from django.core.wsgi import get_wsgi_application
     #
     try:
         dotted = settings.WSGI_APPLICATION
     except AttributeError:  # pragma nocover
         dotted = None
     if dotted:
         app = module_attribute(dotted)
     else:
         app = get_wsgi_application()
     green_workers = self.cfg.greenlet if self.cfg else 0
     if greenio and green_workers:
         if pg:
             pg.make_asynchronous()
         app = greenio.RunInPool(app, green_workers)
         self.green_safe_connections()
     else:
         app = middleware_in_executor(app)
     return WsgiHandler((wait_for_body_middleware, app))
Пример #10
0
 def setup(self, environ=None):
     app = FlaskApp()
     return wsgi.WsgiHandler((wsgi.wait_for_body_middleware,
                              wsgi.middleware_in_executor(app)))
Пример #11
0
 def setup(self, environ=None):
     app = FlaskApp()
     return wsgi.WsgiHandler(
         (wsgi.wait_for_body_middleware, wsgi.middleware_in_executor(app)))